HTML <table> Tag
Description
The <table>
HTML element serves as a container for elements that define the contents of the table. Any table consists of rows and cells, which are specified using the <tr>
and <td>
elements. The following elements are allowed inside the <table>
: <caption>
, <col>
, <colgroup>
, <tbody>
, <td>
, <tfoot>
, <th>
, <thead>
and <tr>
.
Properties
- Permitted Parents
- Any element that accepts flow content
- Content
- An optional <caption>, zero or more <col> or <colgroup> tags, optional <thead> and <tfoot>, zero or more <tbody> tags and at least one <tr>
- Start/End Tags
- Start tag: required, End tag: required
Example
<table border="1">
<tr>
<td>Cat</td>
<td>Dog</td>
</tr>
<tr>
<td>Mouse</td>
<td>Bird</td>
</tr>
</table>
Attributes
Attribute | Definition |
---|---|
summary | Provides a summary of the table's structure and purpose for non-visual user agents. |
align | Visual alignment of the table (i.e. left, center, right). This attribute is deprecated, use CSS instead. |
width | Width of the table. |
bgcolor | Background color of the table. |
frame | Used in conjunction with the border attribute,
specifies which side of the frame that makes up the
border surrounding the table is displayed. Possible values:
|
rules | Used in conjunction with the border
attribute, specifies which rules appear between the
cells of the table. Possible values:
|
border | Specifies the width of the border around the table. For no border, use 0 (zero). |
cellspacing | Specifies the space between cells. |
cellpadding | Specifies the space between the cell borders and their contents |
Global Attributes
The <table>
tag also supports the Global Attributes in HTML5
Event Attributes
The <table>
tag also supports the Event Attributes in HTML5
Browser Support
The following table will show you the current browser support for the HTML <table>
tag.
Desktop | |||||
12 | 1 | 1 | 12.1 | 1 |
Tablets / Mobile | |||||
18 | 4 | 12.1 | 1 | 1 | 4.4 |
Last updated by CSSPortal on: 30th September 2023