HTML class attribute with spaces, it is a W3C valid class?

前端 未结 4 1532
南旧
南旧 2020-11-27 18:35

About HTML class attribute, that assigns CSS class (or classes?) to a tag. The use of spaces, like in

....
         


        
4条回答
  •  臣服心动
    2020-11-27 18:54

    This is supported in IE 7 and up, including all modern, non-IE browsers. As other commenters have pointed out, it is actually a list of classes, not a single class with spaces.

    A better way to understand this is to give your example a few more options:

    ....
    ....
    ....
    

    .a.b {} in your css will target the first tag.
    .a {} will target the first and second tags.
    .b {} will target the first and third tags.

    This is why using multiple classes on a single element can be very helpful.

    For questions of CSS selectors and pseudo selectors, I like to use this (slightly outdated) table http://kimblim.dk/css-tests/selectors/

提交回复
热议问题