HTML TABLE

After this lesson you should be able to comfortably insert a table to your website

In HTML, you can create tables for your website using the <table> tag in conjunction with the <tr><td> and <th> tags.

Each table row is defined with a <tr> tag. Each table header is defined with a <th> tag. Each table data/cell is defined with a <td> tag.

By default, the text in <th> elements are bold and centered.

By default, the text in <td> elements are regular and left-aligned.

You can use the <caption> element to specify a caption for tables. It should be placed immediately after the opening <table> tag

Example

<!DOCTYPE html>

<html>

<head>

<title> </title>

</head>

<header> </header>

<body>

<table>

<caption> class list </caption>

<tr>

    <th> name </th>

    <th> class  </th>

    <th> Age </th>

 </tr>

 <tr>

    <td> Jill </td>

    <td> 4 </td>

    <td> 10 </td>

  </tr>

  <tr>

    <td> Eve </td>

    <td> 5 </td>

    <td> 12 </td>

  </tr>

  <tr>

    <td> mike </td>

    <td> 7 </td>

    <td> 14 </td>

  </tr>

  <tr>

    <td> tim </td>

    <td> 2 </td>

    <td> 8 </td>

</tr>

</table>

</body>

</html>




Let’s review what we have learnt so far about table
<table> element to define a table
<tr> element to define a table row
<td> element to define a table data
<th> element to define a table heading
<caption> element to define a table caption
Scroll to Top