HTML table tag is used to display data in tabular form (row * column). There can be many columns in a row.
We can create a table to display data in tabular form, using
element, with the help of ,, and | elements. |
---|
In Each table, table row is defined by tag, table header is defined by , and table data is defined by tags.
HTML tables are used to manage the layout of the page e.g. header section, navigation bar, body content, footer section etc.
But it is recommended to use div tag over table to manage the layout of the page .
Tag | Description |
---|---|
<table> | It defines a table. |
<tr> | It defines a row in a table. |
<th> | It defines a header cell in a table. |
<td> | It defines a cell in a table. |
<caption> | It defines the table caption. |
<colgroup> | It specifies a group of one or more columns in a table for formatting. |
<col> | It is used with <colgroup> element to specify column properties for each column. |
<tbody> | It is used to group the body content in a table. |
<thead> | It is used to group the header content in a table. |
<tfooter> | It is used to group the footer content in a table. |
<table> <tr> <th>Name</th><th>Location</th><th>IELTS Marks</th> </tr> <tr> <td>Alice</td><td>London</td><td>60</td> </tr> <tr> <td>Sam</td><td>Paris</td><td>80</td> </tr> <tr> <td>Sunny</td><td>New York</td><td>82</td> </tr> <tr> <td>Charles</td><td>Berlin</td><td>72</td> </tr> </table>
Name | Location | IELTS Marks |
---|---|---|
Alice | London | 60 |
Sam | Paris | 80 |
Sunny | New York | 82 |
Charles | Berlin | 72 |