What's the difference between CSS3's :root pseudo class and html?

后端 未结 3 533
长发绾君心
长发绾君心 2020-12-08 09:26

I can\'t seem to find much information about this.

Smashing Magazine seems to be saying that html and :root are the same thing but surely t

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 09:48

    From the W3C wiki:

    The :root pseudo-class represents an element that is the root of the document. In HTML, this is always the HTML element.

    CSS is a general purpose styling language. It can be used with other document types, not only with HTML, it can be used with SVG for example.

    From the specification (emphasis mine):

    This specification defines Cascading Style Sheets, level 2 revision 1 (CSS 2.1). CSS 2.1 is a style sheet language that allows authors and users to attach style (e.g., fonts and spacing) to structured documents (e.g., HTML documents and XML applications).

提交回复
热议问题