colgroup is a container for a number of
col elements, and allows you to set attributes that you
might otherwise set at
col level on a number of
col elements simultaneously—the attributes defined at
this higher level apply to all of the child columns. It is important to
note that if you use one or more
colgroup then all
cols must be enclosed in one or more
colgroup element is used to set a
class for first three columns (which can then be
styled with CSS):
<table border="1"> <colgroup class="vivid"> <col/> <col/> <col/> </colgroup> <colgroup> <col/> </colgroup> <tr> <th colspan="4">Work Contact Points</th> </tr> ⋮ </table>
Use This For …
This element is used to apply styles (either using HTML attributes or via CSS) to a number of columns simultaneously.
This element has reasonable support, though the breadth of support depends heavily on which attributes are applied. Attribute support varies between browsers (it would be so much easier if all browsers tested, supported, and ignored the same set of attributes, but unfortunately, this is not the case).
better approach is to apply
class names to the
colgroup elements, then let CSS styling take
care of alignment, colors, widths, and so on.
While the chart shows support as “full”, this is on the understanding that you haven’t yet applied one of the many troublesome or ignored attributes that are listed below (these individual attributes paint a very different picture on browser support!).