Grouping Table Columns: The col Element

If you are very concerned about accessibility, or if your data tables are long, it becomes helpful to group columns to keep them organized and logical. Two elements can assist you with grouping columns for better management and accessibility.

The first of these elements is the col element. The col element is a way to group columns to specify attributes or apply style.

The col element must appear after the caption element, if one exists, and it supports a number of attributes. Of particular importance is the span attribute, which defines how many columns the col element will span.

Example 4-14 demonstrates the use of the col element with a span attribute of 2. You'll notice I've also added the width ...

Get Spring Into HTML and CSS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.