HTML and CSS Reference
In-Depth Information
Figure 2-10. A table with multiple columns: there are three column groups here, headed by
“Name,” “Place of residence,” and “Date of birth"
Reading along the uppermost headers, you can see that this table has three groups of
columns, with the final column spanning the width of three cells. Using colgroup ,
you can define that structure at the start of the table like so:
<table>
<colgroup></colgroup> <colgroup></colgroup> <col-
group span="3"></colgroup>
<tr>
With this markup, you're saying that this table contains three groups of columns, the
first two of which contain a single column (a single column is implied; you don't need
to add a span="1" attribute in this case), and the third group contains three columns.
As shown in Table 2-10 , there exists a col element, a self-closing element that also
has a span attribute and that's used for specifying the existence of columns within a
colgroup . Functionally and semantically, it's practically the same as colgroup , but
unfortunately the HTML specification does not allow for nested colgroup elements,
so you must use col instead. Using the preceding example, you can specify the final set
of three columns in two different ways, either with one col per column, like this:
<table>
<colgroup></colgroup> <colgroup></colgroup> <col-
group> <col /> <col /> <col />
</colgroup>
<tr>
 
Search WWH ::




Custom Search