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:
  • void: None are displayed. This value is the default
  • above: Top side of the frame
  • below: Bottom side of the frame
  • hsides: Top and bottom sides
  • vsides: Right and left sides
  • lhs: Left side
  • rhs: Right side
  • box: All sides
  • border: All sides
rules Used in conjunction with the border attribute, specifies which rules appear between the cells of the table. Possible values:
  • None: None are displayed. This value is the default
  • groups: Rules appear between row groups and column groups
  • rows: Between rows
  • cols: Between columns
  • all: Between all rows and columns
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

Desktop
Explorer Edge Chrome Firefox Opera Safari
YesYes11YesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
1184YesYesYes

Last updated by CSSPortal on: 6th December 2019