div.classname in css file

后端 未结 12 680
臣服心动
臣服心动 2020-12-10 02:21

I have seen some developers write

HTML:

some content

CSS:

12条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 02:56

    Exactly.

    This is from the W3C spec:

    For example, we can assign style information to all elements with class~="pastoral" as follows:

    *.pastoral { color: green }  /* all elements with class~=pastoral */
    or just .pastoral { color: green }  /* all elements with class~=pastoral */ 
    

    The following assigns style only to H1 elements with class~="pastoral":

    H1.pastoral { color: green }  /* H1 elements with class~=pastoral */
    

    Given these rules, the first H1 instance below would not have green text, while the second would:

    Not green

    Very green

提交回复
热议问题