Re: <colgroup>: WAI tutorial vs HTML 5 spec

Thanks. Good to know, because the HTML5 spec as written is super 
confusing. It says both that you can omit <colgroup> and that <col> must 
be a child of <colgroup>. It seems pretty emphatic about the latter.

About <colgroup> tag omission:

"- A|colgroup 
<https://html.spec.whatwg.org/multipage/tables.html#the-colgroup-element>|element'sstart 
tag 
<https://html.spec.whatwg.org/multipage/syntax.html#syntax-start-tag>can 
be omitted if the first thing inside the|colgroup 
<https://html.spec.whatwg.org/multipage/tables.html#the-colgroup-element>|element 
is a|col 
<https://html.spec.whatwg.org/multipage/tables.html#the-col-element>|element, 
and if the element is not immediately preceded by another|colgroup 
<https://html.spec.whatwg.org/multipage/tables.html#the-colgroup-element>|element 
whoseend tag 
<https://html.spec.whatwg.org/multipage/syntax.html#syntax-end-tag>has 
been omitted. (It can't be omitted if the element is empty.)

- A|colgroup 
<https://html.spec.whatwg.org/multipage/tables.html#the-colgroup-element>|element'send 
tag 
<https://html.spec.whatwg.org/multipage/syntax.html#syntax-end-tag>can 
be omitted if the|colgroup 
<https://html.spec.whatwg.org/multipage/tables.html#the-colgroup-element>|element 
is not immediately followed byASCII whitespace 
<https://infra.spec.whatwg.org/#ascii-whitespace>or acomment 
<https://html.spec.whatwg.org/multipage/syntax.html#syntax-comments>."

About <col> context of use:

"Contexts in which this element can be used 
<https://html.spec.whatwg.org/multipage/dom.html#concept-element-contexts>:
- As a child of a|colgroup 
<https://html.spec.whatwg.org/multipage/tables.html#the-colgroup-element>|element 
that doesn't have a|span 
<https://html.spec.whatwg.org/multipage/tables.html#attr-col-span>|attribute.

If a|col 
<https://html.spec.whatwg.org/multipage/tables.html#the-col-element>|element 
has a parent and that is a|colgroup 
<https://html.spec.whatwg.org/multipage/tables.html#the-colgroup-element>|element 
that itself has a parent that is a|table 
<https://html.spec.whatwg.org/multipage/tables.html#the-table-element>|element, 
then the|col 
<https://html.spec.whatwg.org/multipage/tables.html#the-col-element>|elementrepresents 
<https://html.spec.whatwg.org/multipage/dom.html#represents>one or 
morecolumns 
<https://html.spec.whatwg.org/multipage/tables.html#concept-column>in 
thecolumn group 
<https://html.spec.whatwg.org/multipage/tables.html#concept-column-group>represented 
by that|colgroup 
<https://html.spec.whatwg.org/multipage/tables.html#the-colgroup-element>|."

All the best,

Jeff

On 2022-12-19 1:39 p.m., David Woolley wrote:
> On 19/12/2022 18:17, Jeff Orchard wrote:
>> According to the HTML spec, <col> must be a child of <colgroup>. Is 
>> this equivalent?
>
> But the begin and end tags for colgroup can often be omitted.
>
> The equivalent, with full tagging, is:
>
> <colgroup>
> <col>
> </colgroup>
> <colgroup span="2"></colgroup>
> <colgroup span="2"></colgroup>
>
>

Received on Monday, 19 December 2022 19:13:45 UTC