HTML <table> Tag

Description:

The <table> tag defines an HTML table.

A simple HTML table consists of the table element and one or more tr, th, and td elements.

The tr element defines a table row, the th element defines a table header, and the td element defines a table cell.

A more complex HTML table may also include caption, col, colgroup, thead, tfoot, and tbody elements.

 

Specific 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.

Other Attributes:

Attribute Definition
dir

Specifies the text direction for the content in an element.
Possible Values:

  • rtl  (Right to Left)
  • ltr  (Left to Right)
class Specifies a classname for an element.
id Specifies a unique id for an element.
lang Specifies a language code for the content in an element.
title Specifies a title to associate with the element. Many browsers will display this when the cursor hovers over the element (similar to a "tool tip").
style Specifies an inline style for an element.
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

Example Code:

<table border="1">
  <tr>
    <td>Cat</td>
    <td>Dog</td>
  </tr>
  <tr>
    <td>Mouse</td>
    <td>Bird</td>
  </tr>
</table>

Result
Cat Dog
Mouse Bird