FREE HTML CODE
Search HTML Code

HTML Table Code

You can use the following HTML code to create a table in your HTML document. You can set the border to zero if you want the table border to be transparent.

You can also check out the HTML Table Generator.

Example HTML Table Code

HTML Code:


<table border="1" cellpadding="5" cellspacing="5" width="100%">
<tr>
<th>Table header</th>

<th>Table header</th>
</tr>
<tr>
<td width="20%">Table cell 1</td><td>Table cell 2</td>
</tr>

</table>
This results in:


Table headerTable header
Table cell 1Table cell 2



Templates

You can use the following template as a basis for your HTML table codes. Simply fill in the blanks or remove uneeded attributes.
Since HTML table code is made up of several tags, each tag is presented separately here.

1. The <table> Tag


For an explanation of all the attributes, see the HTML table tag specifications.


<table
 summary=""
 align=""
 width=""
 dir=""
 class=""
 id=""
 lang=""
 title=""
 style=""
 bgcolor=""
 frame=""
 rules=""
 border=""
 cellspacing=""
 cellpadding=""
 onclick=""
 ondbclick=""
 onmousedown=""
 onmouseup=""
 onmouseover=""
 onmousemove=""
 onmouseout=""
 onkeypress=""
 onkeydown=""
 onkeyup="" >

 (td and tr tags go here - see below)

 </table>

2. The <tr> Tag

This tag defines each row in the table.
For an explanation of all the attributes, see the HTML tr tag specifications.


<tr
 dir=""
 class=""
 id=""
 lang=""
 title=""
 style=""
 bgcolor=""
 align=""
 valign=""
 char=""
 charoff=""
 onclick=""
 ondbclick=""
 onmousedown=""
 onmouseup=""
 onmouseover=""
 onmousemove=""
 onmouseout=""
 onkeypress=""
 onkeydown=""
 onkeyup="" >

 (td tags go here - see below)

 </tr>


3. The <th> Tag

This tag is optional and defines a header cell for header content.
For an explanation of all the attributes, see the HTML th tag specifications.



<th
 headers=""
 scope=""
 abbr=""
 axis=""
 rowspan=""
 colspan=""
 nowrap=""
 width=""
 height=""
 dir=""
 class=""
 id=""
 lang=""
 title=""
 style=""
 bgcolor=""
 align=""
 valign=""
 char=""
 charoff=""
 onclick=""
 ondbclick=""
 onmousedown=""
 onmouseup=""
 onmouseover=""
 onmousemove=""
 onmouseout=""
 onkeypress=""
 onkeydown=""
 onkeyup="" >

 (the table header content goes here)

 </th>

4. The <td> Tag

This tag defines each cell in the table - it's where you put the actual content of the table.

For an explanation of all the attributes, see the HTML td tag specifications.


<td
 headers=""
 scope=""
 abbr=""
 axis=""
 rowspan=""
 colspan=""
 nowrap=""
 width=""
 height=""
 dir=""
 class=""
 id=""
 lang=""
 title=""
 style=""
 bgcolor=""
 align=""
 valign=""
 char=""
 charoff=""
 onclick=""
 ondbclick=""
 onmousedown=""
 onmouseup=""
 onmouseover=""
 onmousemove=""
 onmouseout=""
 onkeypress=""
 onkeydown=""
 onkeyup="" >

 (the table content goes here)

 </td>
| More