Creating Tables


You can create several different types of tables using HTML. The simplest type of table is one where there are no borders, only rows and columns. The text within a cell of a table can be either right, left, or center alignment. If no align command is used the text is automatically aligned to the left edge of the table. The align=center command in the example below centers the data. Note that the table begins with a <table> tag and ends with a </table> tag. Note also that each bit of data is represented by a <td> tag and the <tr> tag is used to start a new row.

<html>
<head>
<title>Simple Table</title> 
</head> 
<body>
<h2>Simple table with no borders.</h2>
<table> 
<tr> 
<td align=center><h3>Element</h3>
<td align=center><h3>Symbol</h3> 
<tr>
<td><h4>Carbon</h4> 
<td align=center><h4>C</h4> 
<tr> 
<td><h4>Oxygen</h4> 
<td align=center><h4>O</h4>
</table>
</body> 
</html>

Display this table


You can also add borders to your tables and the border style can be changed. The table border command determines the width of the border while the cellpadding and cellspacing commands control how the cells of data are separated.

<table border=8 cellpadding=2 cellspacing=2>
<tr>
<td align=center><b>Element</b>
<td align=center><b>Symbol</b> 
<tr> 
<td align=center>Carbon 
<td align=center>C 
<tr> 
<td align=center>Oxygen 
<td align=center>O 
</table>

Display this table


Return to HTML Tutorial Menu