Table Content - tbody

The tbody element is what contains the actual content of the table itself. What goes in here is the tabular data that is the reason for defining a table in the first place. The content of the tbody is defined in a very simpler way to the way that you define the content of the thead and tfoot elements of the table in that you have tr rows that contain td details. The actual content goes within the td containers.

Where it differs from the thead and tfoot is that you can actually have more than one tbody within the same table. It is rather rare that you would need to do this but it may be useful if you have two or more sections within your table where you need to apply different styles.

We'll continue with our three columns example and imagine that we also need two rows within our content as well.

<td>row 1, Col 1</td>
<td>row 1, Col 2</td>
<td>row 1, Col 3</td>
<td>row 2, Col 1</td>
<td>row 2, Col 2</td>
<td>row 2, Col 3</td>

You may see tables defined on some web pages where the tbody container is omitted and the rows of the table are contained directly within the table container. Those tables are in fact incorrectly defined and the only reason that they work is that browsers will automatically add the tbody container around the body of the table if you leave it out.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow