table
Summary
The <table> element is a wrapper for an HTML table. It defines the start and end of a table, and can contain other table elements, such as <tr>.
Overview Table
The <table>
element is a container for HTML table data, which is used to mark up tabular data. Tabular data is any data that can be systematically displayed in rows and columns, for example, “See table 3 for an example.”
Tables were often used for laying out web pages because tables helped fix the position of text on the page, however, this use has become an outdated. We recommend you use <div>
and <span>
for fixed layouts. You can still use tables for tabular data.
You might find working with an HTML table editor easier than coding tables by hand, unless you are especially adept at visualizing table row and columns using the appropriate HTML tags. It is easy to miss or drop a tag when coding tables manually, which will cause your table to be malformed.
Examples
This example uses the tbody element with the ****table****, td, thead, and tr elements to create a table with the first row in the table head and the second row in the table body.
<table>
<thead>
<tr>
<td>
This text is in the thead.
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
This text is in the tbody.
</td>
</tr>
</tbody>
</table>
Usage
At the most simple level you need to use the following three groups of tags to create a basic table.
creates a column space while | ends the column space. These are usually nested inside a pair of