wai-tutorials icon indicating copy to clipboard operation
wai-tutorials copied to clipboard

Code snippet featuring 'col' and 'colspan' differs from general practice and from source of own example

Open ghost opened this issue 3 years ago • 2 comments

Hi,

Re: the Example (rendered HTML table) and Code Snippet here https://www.w3.org/WAI/tutorials/tables/irregular/#table-with-two-tier-headers

The Example table (when you examine it) uses the following markup:

<colgroup>
<col>
</colgroup>
<colgroup span="2"></colgroup>
<colgroup span="2"></colgroup>

yet the Code Snippet provided uses this:

<col>
<colgroup span="2"></colgroup>
<colgroup span="2"></colgroup>

While both may be valid, I note that MDN introduce col by saying:

The HTML <col> element defines a column within a table and is used for defining common semantics on all common cells. It is generally found within a <colgroup> element.

Assuming MDN is correct, and col is generally found within a <colgroup> element, and given the actual table on the page follows that usage, I think it would be better if the Code Snippet were changed to match the HTML used by the table, i.e. with col inside a colgroup.

Thanks for these pages on tables, they are invaluable and visited by me repeatedly when coding complex tables. Brilliant!

Cheers,

Alan

ghost avatar Nov 19 '20 13:11 ghost

Update: <colgroup> and <col> only needed for HTML 4?

I am attempting to find any reference to <colgroup> and <col> (elements, not attributes) being useful for anything other than perhaps styling (which we can do with CSS in the absence of these two). So far all I seem to find is related to HTML 4.01, not HTML 5.

If, as it seems, <colgroup> and <col> are only needed for HTML 4.01 and are redundant or at least of no help for a11y, in HTML5, it would be very helpful if this were noted.

ghost avatar Nov 19 '20 19:11 ghost

You can see in the code that the raw HTML text has only <col> specified, the opening and closing <colgroup> tags are optional and hence not specified. In the DOM, they get added automatically.

I don’t think there is an HTML4/5 difference. Yes, colgroups and cols can be used for styling, but they also provide semantic grouping, that can affect header calculations.

yatil avatar Feb 09 '21 12:02 yatil