Defines a table used for tabular data.. The HTML <table> tag is used for defining a table. The <table> tag contains other tags that define the structure of the table.

Table Elements

Tables consist of the <table> element as well as other table-related elements. These other elements are nested inside the <table> tags to determine how the table is constructed.

The children of a <table> element must be, in order:

  1. Zero or one <caption> elements
  2. Zero or one <colgroup> elements
  3. Zero or one <thead> elements
  4. Zero or one <tfoot> elements (but only if the last element in the table is not a <tfoot> element)
  5. Either:
    • Zero or more <tbody> elements, or
    • One or more <tr> elements (these represent the table rows)
  6. Zero or one <tfoot> elements (but only if there are no other <tfoot> elements in the document)

Each <tr> element represents a row in the table. A row can have one or more <td> or <th> elements, which determine the columns in the table. Specifically, <td> represents table data and <th> represents a table header.

Required Attributes

  • None.

Optional Attributes

  • summary can be used to provide a summary of the data represented in the table.
  • Common attributes

Example

<table>
	<tr>
		<th>Name</th>
		<th>Nationality</th>
	</tr>
	<tr>
		<td>John</td>
		<td>English</td>
	</tr>
	<tr>
		<td>Pedro</td>
		<td>Portuguese</td>
	</tr>
</table>

Changes in HTML5

  • None.

Related Tags