table
Definition and Usage
Thetable
element represents a table.The table tag displays information in rows and columns.These allow authors to represent tabular data in a document. tabular data —that is, information expressed via a two-dimensional data table. In the code, a table basically consists of a group of rows that contain, each, a group of cells.
The HTML <table>
tag is used for defining a table in an HTML document. The <table>
tag contains other tags that define the structure of the table.
<table>
element as well as other table-related elements. These other elements are nested inside the <table>
tags to determine how the table is constructed.
Each <tr> element represents a row in the table. A row can have one or more <td>or <th> elements, which determine the columns in the table. Specifically, <td> represents table data and <th> represents a table header.
A more complex HTML table may also include <caption>, <col>, <colgroup>, <thead>, <tfoot>, and <tbody> elements
Syntax
The<table>
tag is written as <table>
</table>
with the various table elements nested between the start and end tags.
<table>
<tr> <th>Table Header 1</th>
<th>Table Header 2</th>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td> </tr>
<tr> <td>Cell 3</td>
<td>Cell 4</td> </tr>
</table>