css - css选择器的级别是什么? 3级和4级有什么区别吗?

标签 css css-selectors

我无法理解 CSS 选择器级别的含义。我想知道答案。

我有一个reference关于它,但我无法弄清楚它是如何工作的或它们如何相互关联?

最佳答案

来自the specification

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/

相关文章:

CSS 选择器选择连字符后的第二个元素

css - 为什么我的 *+html CSS 在 IE7 中工作

jquery - 如何在 jQuery 中仅选择元素的直接子元素

javascript - Slick Carousel 上的 Twitter Bootstrap 工具提示

javascript - jQuery 手机 : ui-helper-hidden-accessible

jquery - 在加载 jquery 时,div 弹跳 ui

css - 具有 flex 问题的 Wordpress 两列事件管理器

html - 如何在相对定位的 div 下面堆叠一个 div?

xpath - 无法在 Selenium 中获取第 n 个节点

html - 基于字体粗细的 CSS 选择器?