HTML Table 1
HTML Table 1
</table>
Table Header, Body, and Footer
Tables can be divided into three portions − a header, a
body, and a foot. The head and foot are rather similar to
headers and footers in a word-processed document that
remain the same for every page, while the body is the main
content holder of the table.
The three elements for separating the head, body, and
foot of a table are −
<thead> − to create a separate table header.
<tbody> − to indicate the main body of the table.
<tfoot> − to create a separate table footer.
<html> <head> <title>HTML Table</title> </head>
<body>
<table border = "1" width = "100%">
<thead>
<tr> <td colspan = "4">This is the head of the table</td> </tr>
</thead>
<tfoot>
<tr> <td colspan = "4">This is the foot of the table</td> </tr>
</tfoot>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td> </tr>
</tbody>
</table> </body> </html>
HTML <colgroup> and <col>
The <colgroup> tag specifies a group of one or more columns in a table
for formatting.
The <colgroup> tag is useful for applying styles to entire columns, instead
of repeating the styles for each cell, for each row.
Note: The <colgroup> tag must be a child of a <table> element, after
any <caption> elements and before any <thead>, <tbody>, <tfoot>,
and <tr> elements.
Tip:To define different properties to a column within a <colgroup>, use
the <col> tag within the <colgroup> tag.
The <col> tag specifies column properties for each column within
a <colgroup> element.
The <col> tag is useful for applying styles to entire columns, instead of
repeating the styles for each cell, for each row.
Set the background color of the three columns with the
<colgroup> and <col> tags:
<table>
<colgroup>
<col span="2" style="background-color:red">
<col style="background-color:yellow">
</colgroup>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
</table>