This is an HTML table
.
Tables are defined with the <table>
tag. Each table has multiple rows (defined by the <tr>
tag), and each row is divided into cells (defined by the <td>
tag). The letters "td" stand for table data, which is the content of the data cell.
Data cells can contain text, images, lists, paragraphs, forms, horizontal lines, tables, and more.
HTML Table Generator: https://c.tutorialpro.org/front-end/7688/.
HTML Table Example:
First Name | Last Name | Points |
---|---|---|
Jill | Smith | 50 |
Eve | Jackson | 94 |
John | Doe | 80 |
Adam | Johnson | 67 |
Online Example
Example
<h4>One column:</h4>
<table border="1">
<tr>
<td>100</td>
</tr>
</table>
<h4>One row and three columns:</h4>
<table border="1">
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
</table>
<h4>Two rows and three columns:</h4>
<table border="1">
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
</table>
(More examples can be found at the bottom of this page.)
Table Example
Example
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
It will display in the browser as follows:
HTML Tables and Border Attributes
If the border attribute is not defined, the table will not display a border. This can be useful sometimes, but most of the time, we want to show a border.
Use the border attribute to display a table with a border:
Example
<table border="1">
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>
HTML Table Headers
Table headers are defined with the <th>
tag.
Most browsers will display the header as bold and centered text:
Example
<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
It will display in the browser as follows:
More Examples
Table cells spanning multiple rows or columns
HTML Table Tags
Tag | Description |
---|---|
<table> | Defines a table |
<th> | Defines a table header |
<tr> | Defines a table row |
<td> | Defines a table cell |
<caption> | Defines a table caption |
<colgroup> | Defines a group of columns in a table |
<col> | Defines column properties for each column within a <colgroup> element |
<thead> | Defines a header section of the table |
<tbody> | Defines a body section of the table |
<tfoot> | Defines a footer section of the table |