HTML and CSS Reference
In-Depth Information
Figure 2-9. A basic table using the rowspan attribute
A table cell can span both rows and columns if necessary. You just need make sure
your cells and spans add up. For instance, if your table has two rows, one containing
five td elements, then the second row can span only up to five cells—any more than
that and the table will not be valid and will render unpredictably, and any fewer than that
and the slack must be taken up by remaining cells.
I've heard it suggested in the past that rowspan and colspan are presentational
and should be avoided, but this is incorrect; you're using the attributes to define struc-
ture, not presentation, so you should keep that information in the markup.
As you may have noticed by now, most of the table markup presented so far relates
only to rows and individual cells within those rows—there is no tc element. Instead,
we have two elements that can define columns and groups of columns, and both are op-
tional: col and colgroup .
The colgroup element allows you to specify how many groups of columns will ex-
ist in the table (so one colgroup per group of columns, and a group can contain just
one column) and how many columns are contained within each group with the use of a
span attribute and a numerical value. This element is placed directly after the opening
table tag, and it does not contain any markup other than optional col tags, described
shortly.
Consider, for example, the table shown in Figure 2-10 .
 
Search WWH ::




Custom Search