What is the css / html `root` element?

后端 未结 6 1748
Happy的楠姐
Happy的楠姐 2020-12-30 20:18

I have just recently started using NetBeans IDE (6.9.1) and have used it to add a stylesheet to my site-in-progress.

To my surprise, one element was automatically ad

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-30 21:20

    There is a difference between root and html, the root pseudo-class is a CSS3 entity, and does not affect older browsers (MSIE 8 or less, Opera 9.4 or less)

    html /* for all web browsers */
    {
        color:red; 
    }
    

    You have to put a colon before the word root as follows...

    :root /* for CSS3 web browsers: Chrome, Firefox, MSIE 9+, Safari, Opera 9.5+ */
    {
        color:blue;
    }
    

    If you used both of these CSS lines, MSIE version 8 or less (or MSIE 9+ when running in compatibility mode, which renders as MSIE 7) would show red text, most other browsers would show blue text.

    Documentation and specs for 'root' can be found at the Mozilla Developer Network: https://developer.mozilla.org/en-US/docs/Web/CSS/:root

提交回复
热议问题