我无法理解 CSS 选择器级别的含义。我想知道答案。
我有一个reference关于它,但我无法弄清楚它是如何工作的或它们如何相互关联?
最佳答案
Cascading Style Sheets does not have versions in the traditional sense; instead it has levels. Each level of CSS builds on the previous, refining definitions and adding features
在 CSS 中,每个新级别都会为前一个级别添加新功能。就如此容易。从 CSS Level 3 开始,此逻辑将应用于每个模块:
CSS Level 3 builds on CSS Level 2 module by module, using the CSS2.1 specification as its core. Each module adds functionality and/or replaces part of the CSS2.1 specification. The CSS Working Group intends that the new CSS modules will not contradict the CSS2.1 specification: only that they will add functionality and refine definitions. As each module is completed, it will be plugged in to the existing system of CSS2.1 plus previously-completed modules.
From this level on modules are levelled independently: for example Selectors Level 4 may well be completed before CSS Line Module Level 3. Modules with no CSS Level 2 equivalent start at Level 1; modules that update features that existed in CSS Level 2 start at Level 3.
CSS 选择器 Level 4 是针对 CSS 选择器编写的最新规范,它是 Level 3 的改进。您可以清楚地看到每个级别都在添加新的选择器。
您真的不需要为级别而烦恼。您需要了解的只是选择器以及如何使用它们,尤其是它们的浏览器支持。 (一个可以帮助您的有用工具:https://caniuse.com/)
每个级别的规范如下:
https://www.w3.org/TR/selectors-4/
https://www.w3.org/TR/selectors-3/
您还可以在最后一个规范的末尾找到一个名为 Changes Since Level 3 的部分。
关于css - css选择器的级别是什么? 3级和4级有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65518954/