انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents
Robo Web: home
0. Lab tour1
1. HTML: the page's content7
2. CSS: the page's look6
3. JavaScript: the actions7
4. The project: the to-do list3
5. Pro CSS: shadows and movement5
6. Arrays and building the page with code3
7. Events and forms3
8. Objects and time3
9. Canvas: drawing and games3
10. The final project: the memory game3

The table

Section 1: HTML: the page's contentLesson 1.5 · ⏱ 7 min

<table> is a table, every row is <tr>, a heading cell is <th>, and a normal cell is <td>.

HTML
<h1>My marks</h1>
<table>
  <tr><th>Subject</th><th>Mark</th></tr>
  <tr><td>Math</td><td>95</td></tr>
  <tr><td>Science</td><td>90</td></tr>
  <tr><td>Arabic</td><td>88</td></tr>
</table>
CSS
body { font-family: Tahoma; }
td, th { border: 1px solid #999; padding: 6px 12px; }
🖥️ The page in Robo Web:The page in Robo Web

📌 Another example: the school timetable

The headings row uses th, and every day is a tr row.

🌐 The school timetable
HTML
<table>
  <tr><th>Day</th><th>First lesson</th><th>Second lesson</th></tr>
  <tr><td>Sunday</td><td>Maths</td><td>Science</td></tr>
  <tr><td>Monday</td><td>Arabic</td><td>Coding</td></tr>
</table>
CSS
body { font-family: Tahoma, sans-serif; }
table { border-collapse: collapse; }
th, td { border: 1px solid #999; padding: 6px 12px; }
th { background: #E8F0FF; }
🖥️ The page in Robo Web:The page in Robo Web
✍️ Practise
The table.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

A table with two rows and two columns: the name and the age.

👀 Show the solution
🌐 Solution
HTML
<table border="1">
  <tr><td>Ali</td><td>10</td></tr>
  <tr><td>Mona</td><td>9</td></tr>
</table>
CSS
body { font-family: Tahoma, sans-serif; }
🖥️ The page in Robo Web:The page in Robo Web

Result: a 2 × 2 table.

Medium

Add a coloured th headings row.

👀 Show the solution
🌐 Solution
HTML
<table border="1">
  <tr><th>Name</th><th>Age</th></tr>
  <tr><td>Ali</td><td>10</td></tr>
  <tr><td>Mona</td><td>9</td></tr>
</table>
CSS
body { font-family: Tahoma, sans-serif; }
th { background: gold; }
🖥️ The page in Robo Web:The page in Robo Web

Result: the headings row is gold.

Hard

The 2 times table: three rows (2×1, 2×2, 2×3) with the answer in a column.

👀 Show the solution
🌐 Solution
HTML
<table border="1">
  <tr><th>The sum</th><th>The answer</th></tr>
  <tr><td>2 × 1</td><td>2</td></tr>
  <tr><td>2 × 2</td><td>4</td></tr>
  <tr><td>2 × 3</td><td>6</td></tr>
</table>
CSS
body { font-family: Tahoma, sans-serif; }
td, th { padding: 4px 14px; }
🖥️ The page in Robo Web:The page in Robo Web

Result: four rows.

Finished the lesson? Mark it so your progress counts.