Back to the html tags list

HTML Tags - <table> Tag

Description

Definition

The <table> tag can create tables in HTML, but you must include the <tr> and <td> tags (see the example).

Where To Use The Tag

The <table> tag can be used anywhere between the <body> tags. The <table> tag is a block-level tag so you may use inline and block-level tags inside this tag.

Example

Code Output
<table border="1">
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
</table>

Row 1, Cell 1 Row 1, Cell 2


Notes

  • You must include the 'border' attribute in the table tag, for borders to show

  • The 'align' and 'bgcolor' attributes are deprecated in HTML 4.01, and are not supported in XHTML 1.0 Strict !DOCTYPE

Attributes for the table tag

Attribute

Description

Value(s)

DOCTYPE

Strict DOCTYPE Attributes

border

Specifies if this tag has a border or not, also how wide the border is.

pixels (px)

Strict, Transitional and Frameset

cellpadding

Sets the amount of space between the cells content and the cells border.

Pixels (px)

Strict, Transitional and Frameset

cellspacing

Sets the amount of space between cells.

Pixels (px)

Strict, Transitional and Frameset

frame

Defines the borders to be shown, borders must be set higher then 0. ie. border="1"

above
below
border
box
hsides
lhs
rhs
void
vsides

Strict, Transitional and Frameset

rules

Defines what vertical or/and horizontal lines to hide, or show. Borders must be set higher then 0. ie. border="1"

all
cols
groups
none
rows

Strict, Transitional and Frameset

summary

Strict, Transitional and Frameset

width

Strict, Transitional and Frameset

Non-Strict DOCTYPE Attributes

align

Transitional and Frameset

bgcolor

Transitional and Frameset

Common attributes for the table tag

class, style, id, title, dir, xml:lang, lang

Details for Common html Attributes.

Javascript Event attributes for the table tag

onmousedown, onmouseup, onclick, ondblclick, onmouseover, onmouseout, onmousemove, onkeydown, onkeyup, onkeypress

Details for Javascript Event Attributes.


Back to the html tags list