The HTML <table> tag is used for defining a table. The table tag contains other tags that define the structure of the table.
<!DOCTYPE html>
<html>
<head>
<title>HTML table Tag</title>
</head>
<body>
<table border="1">
<tr>
<th>Team</th>
<th>Ranking</th>
</tr>
<tr>
<td>India</td>
<td>1</td>
</tr>
<tr>
<td>South Africa</td>
<td>2</td>
</tr>
<tr>
<td>Australia</td>
<td>3</td>
</tr>
</table>
</body>
</html>
This will produce following result:
Team | Ranking |
---|---|
India | 1 |
South Africa | 2 |
Australia | 3 |
The HTML <table> tag also supports following additional attributes:
Attribute | Value | Description |
---|---|---|
abbr | abbreviated_text | Deprecated-Specifies an abbreviated version of the content in a cell. |
align | right left center justify char |
Deprecated-Visual alignment. |
bgcolor | rgb(x,x,x) #hexcode colorname |
Deprecated-Specifies the background color of the table. |
border | pixels | Deprecated-Specifies the border width. A value of "0" means no border. |
cellpadding | pixels or % | Deprecated-Specifies the space between the cell borders and their contents. |
cellspacing | pixels or % | Deprecated-Specifies the space between cells. |
frame | void above below hsides lhs rhs vsides box border |
Deprecated-Used in conjunction with the border attribute, specifies which side of the frame that makes up the border surrounding the table is displayed. |
rules | none groups rows cols all |
Deprecated-Used in conjunction with the border attribute, specifies which rules appear between the cells of the table. |
summary | text | Deprecated-Specifies the summary of the content. |
width | pixels or % | Deprecated-Specifies the width of the table. |