Span attribute on colgroup and col

前端 未结 2 844
眼角桃花
眼角桃花 2021-01-06 18:30

Are these codes logically equivalent?



And


2条回答
  •  粉色の甜心
    2021-01-06 18:54

    From the specification for :

    Contexts in which this element can be used:
    As a child of a colgroup element that doesn't have a span attribute.
    [...]
    Content attributes: Global attributes
    span

    I read that as saying that just on its own is invalid but this:

    
        
    
    

    is valid and the same as:

    
    
    

    However, if the has a span attribute, then it should not have children:

    If the colgroup element contains no col elements, then the element may have a span content attribute specified...

    My interpretation (based on the HTML4 specification more than the thinner HTML5 one) is that you would usually use unless you needed to style one of the columns in the group differently as in this (modified) example from the HTML4 specification:

    
        
        
    
    

    so the first 39 columns would use whatever the specifies but the 40th could be tweaked. OTOH, I'm having trouble getting browsers to pay much attention to any of this (despite what the specs say) on jsfiddle.net so YMMV.

提交回复
热议问题