The <table> tag can create tables in HTML, but you must include the <tr> and <td> tags (see the example). The <table> tag can be used anywhere between the opening and closing <body> tags. It is a block-level tag so you may use inline and block-level tags inside this tag.
Table Example
| Code | Output | ||
|---|---|---|---|
<table border="1"> <tr> <td>Row 1, Cell 1</td> <td>Row 1, Cell 2</td> </tr> </table> |
|
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 | 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 | 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 | ||

Comments