Lesson 8: Tables

Making A Table

We’re talking tables for holding data not the dinner table. Tables were once used in designing webpage layout, but no more, now that's the role of CSS. Still it's worth the time to learn how to make them. A table starts and ends with the table tag:

<table></table>

Between the opening and closing table tags go a couple of other tags, the tr tag:

<tr></tr>

It stands for “table row” and will make up one row across the table. Between the tr tags are found the td tags:

<td></td>

The td stands for “table data” it forms one box called a “cell” which contains content seen on the web page such as text or graphics. Here’s how the table code is put together:

<table border="1">

<tr>
<td>Beagle</td>
<td>Chihuahua</td>
</tr>

<tr>
<td>Terrier</td>
<td>Collie</td>
</tr>

</table>

The border attribute in the table tag puts a border around the cells.

Take a close look at the code, this table will have 2 rows with 2 cells in each row. The stuff between the opening and closing td tags is what will be in each cell:

Beagle Chihuahua
Terrier Collie

Add some space inside a cell with a CSS command in the td tag:

<td style="padding:20px;">Beagle</td>

Result:

Beagle Chihuahua
Terrier Collie


The table can be made larger with a CSS command in the opening table tag:

<table border="1" style="width:300px;">

Result:

Beagle Chihuahua
Terrier Collie

Color can be added to a cell too with a CSS command:

<td style="background:aqua;">Terrier</td>

Result:

Beagle Chihuahua
Terrier Collie

And that folks is how a table is put together.

DID YOU KNOW...?
You can register a website address (called a domain in tech talk) even before you have a website. In fact the longer you wait the more difficult it will be to get one that isn't already taken. More Info

DID YOU KNOW...?
There is more to building a website than just making it. It also needs web hosting so that it can be seen on the internet. More Info