HTML » Tags » table

Version: 3.2, 4.0

Compability: Explorer 4, 5  Netscape 4, 6

Syntax:
<table> ... </table>

The <table> tag is used to designate that this element is a table. A table is a structural presentation of data or information using rows and columns.

The default is that the flow of any text and images is stopped in the HTML document, the table element is inserted starting on the next line, and after the end of the table element is reached, the flow of text and images resumes on the following line. However, the use of attributes and style sheet properties will allow you to embed the table element within the text and images.
 
The insides of the table are constructed using the tr, th, td, and the caption tags. There are also three new table tags that were released with version 4.0. They are tbody, tfoot, and thead.
 
The closing tag is mandatory.
 

Examples

Code:
<table width="80%" border="10" cellpadding="3" cellspacing="5" align="center">
<caption>
<center><b>How To Code A Table</b></center>
<br>
Use the caption tag to name the table and to provide useful information about the contents
</caption>
<tr>
<th colspan="2">Use the <b>th</b> tag to create the header which will display in bold</th>
</tr>
<tr>
<td width="50%">The <b>tr</b> tag creates the row</td>
<td width="50%">The <b>td</b> tag creates individual cells for each row</td>
</tr>
<tr>
<td width="50%">You should always use the closing tags</td>
<td width="50%">You can use a variety of HTML tags inside the cell</td>
</tr>
<tr>
<td width="50%">The three new version 4.0 table tags are <b>tbody, tfoot,</b> and <b>thead</b></td>
<td width="50%">The <b>colspan</b> attribute allows you span more than one cell</td>
</tr>
</table>
Output:
How To Code A Table

Use the caption tag to name the table and to provide useful information about the contents
Use the th tag to create the header which will display in bold
The tr tag creates the rowThe td tag creates individual cells for each row
You should always use the closing tagsYou can use a variety of HTML tags inside the cell
The three new version 4.0 table tags are tbody, tfoot, and theadSetting colspan allows you span more than one cell
Explanation:

This example demonstrates the basic table tags.

Language(s): HTML

See Also: