Example:
Code:
<!-- CSS part -->
<style>
table{
text-align: center;
width: 50%;
border-collapse: collapse;
}
td, th{
border: 2px solid black;
padding: 10px;
}
tr:nth-child(even){ /* For this line, the following css properties will only appli on every even rows. */
background-color: #e6d6d6;
}
</style>
<!-- HTML part -->
<table>
<tr>
<th>Country</th>
<th>Country code</th>
<th>Email</th>
</tr>
<tr>
<td>India</td>
<td>IN</td>
<td>india@google.com</td>
</tr>
<tr>
<td>America</td>
<td>USA</td>
<td>usa@google.com</td>
</tr>
<tr>
<td>Japan</td>
<td>JP</td>
<td>jp@google.com</td>
</tr>
<tr>
<td>China</td>
<td>CN</td>
<td>cn@google.com</td>
</tr>
</table>
Output:
| Country | Country code | |
|---|---|---|
| India | IN | india@google.com |
| America | USA | usa@google.com |
| Japan | JP | jp@google.com |
| China | CN | cn@google.com |
Example:
code:
<table>
<tr>
<td colspan="2">1</td>
<!-- <td>2</td> -->
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
Output
| 1 | 3 | |
| 4 | 5 | 6 |
| 7 | 8 | 9 |
Example:
code:
<table>
<tr>
<td rowspan="3">1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<!-- <td>4</td> -->
<td>5</td>
<td>6</td>
</tr>
<tr>
<!-- <td>7</td> -->
<td>8</td>
<td>9</td>
</tr>
</table>
Output
| 1 | 2 | 3 |
| 5 | 6 | |
| 8 | 9 |
The <tfoot> HTML element encapsulates a set of table rows (<tr> elements), indicating that they comprise the foot of a table with information about the table's columns. This is usually a summary of the columns, e.g., a sum of the given numbers in a column.