<table>
The <table> element defines an HTML table
An HTML table consists of the <table> element and one or more <tr>, <th>, and <td> elements. The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell
A more complex HTML table may also include
- <caption>
- <col>
- <colgroup>
- <colgroup>
- <thead>
- <tfoot>
- <tbody>
Syntax
<table> <!-- 5x3 table -->
<caption></caption> <!-- Optional -->
<tr>
<th></th> <th></th> <th></th>
</tr>
<tr>
<td></td> <td></td> <td></td>
</tr>
<tr>
<td></td> <td></td> <td></td>
</tr>
<tr>
<td></td> <td></td> <td></td>
</tr>
<tr>
<td></td> <td></td> <td></td>
</tr>
</table>
Example
Sample Table
# | Name | Price |
1 | CPU | $234.00 |
2 | Case | $99.00 |
3 | RAM | $50.99 |
4 | HDD | 110.00 |
Styled with the following CSS:
<style>
table {
width:400px;
border:1px solid #00a; }
}
td, th {
padding:10px;
border:1px solid #00a;
text-align:center;
}
tr:nth-child(even) {
background: rgba(0,0,200,.2);
}
</style>
<title>
The <title> element is required in all HTML documents and it defines the title of the document. The <title> element:
- defines a title in the browser toolbar
- provides a title for the page when it is added to favorites
- displays a title for the page in search-engine results
Syntax
<title>Page Title</title>
Example