HTML Tables

HTML tables are mainly used for sorting data, they can also be used for a page layout.

Like in the last section i will not give you the whole page code, as it would take up alot of room. Just simply add the table code to your page.

Structure of a HTML Table

The basic HTML table has 3 different tags, they are: <table>, <tr> and <td>. The <table> tag is used to define that you are starting a table (you must include the border="1" attributes for the borders to show). The <tr> tag specifies a table row and lastly the <td> tag (which is placed inside the <tr> tag) this tag is the table data-cell, this is where your content goes. eg.

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

<tr>
<td>
Row 2, Cell 1
</td>
<td>
Row 2, Cell 2
</td>
</tr>
</table>

Add this code to your page. Take note of how the "Row 1, Cell 1" etc is displayed.


Tips:
  • The <td> tag always goes inside the <tr> tag
  • Specify the border="1" attribute if you want the borders to show
  • For a full detailed tutorial on HTML tables go to: Detailed html table tutorial


In the next section of this beginner HTML tutorial you will learn how to.
Back: Beginner HTML tutorial: Index