我应该在 JSFiddle 中使用 :after 还是 ::after?
Should I use :after or ::after in JSFiddle?
在 CSS3(最新的 CSS)中,我应该使用 ::after 还是 :after? JSFiddle 说我应该改用 2 个冒号。我正在成立一个俱乐部,在那里我教人们 HTML 和 CSS,所以我想确保我教给他们的是正确的东西,因为 JSFiddle 发出的信息可能会使他们感到困惑。我自己也想知道这个。
使用 ::after
语法。如果你检查 the current specification 你可以阅读:
The main differences between the selectors in CSS2 and those in Selectors are:
...
new pseudo-elements, and introduction of the "::" convention for pseudo-elementsref
和
This :: notation is introduced by the current document in order to establish a discrimination between pseudo-classes and pseudo-elements. For compatibility with existing style sheets, user agents must also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line, :first-letter, :before and :after). This compatibility is not allowed for the new pseudo-elements introduced in this specification. ref
的未来规范中找到相同的信息
Because CSS Level 1 and CSS Level 2 conflated pseudo-elements and pseudo-classes by sharing a single-colon syntax for both, user agents must also accept the previous one-colon notation for the Level 1 & 2 pseudo-elements (::before, ::after, ::first-line, and ::first-letter). This compatibility notation is not allowed any other pseudo-elements. However, as this syntax is deprecated, authors should use the Level 3+ double-colon syntax for these pseudo-elements.
在 CSS3(最新的 CSS)中,我应该使用 ::after 还是 :after? JSFiddle 说我应该改用 2 个冒号。我正在成立一个俱乐部,在那里我教人们 HTML 和 CSS,所以我想确保我教给他们的是正确的东西,因为 JSFiddle 发出的信息可能会使他们感到困惑。我自己也想知道这个。
使用 ::after
语法。如果你检查 the current specification 你可以阅读:
The main differences between the selectors in CSS2 and those in Selectors are:
...
new pseudo-elements, and introduction of the "::" convention for pseudo-elementsref
和
的未来规范中找到相同的信息This :: notation is introduced by the current document in order to establish a discrimination between pseudo-classes and pseudo-elements. For compatibility with existing style sheets, user agents must also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line, :first-letter, :before and :after). This compatibility is not allowed for the new pseudo-elements introduced in this specification. ref
Because CSS Level 1 and CSS Level 2 conflated pseudo-elements and pseudo-classes by sharing a single-colon syntax for both, user agents must also accept the previous one-colon notation for the Level 1 & 2 pseudo-elements (::before, ::after, ::first-line, and ::first-letter). This compatibility notation is not allowed any other pseudo-elements. However, as this syntax is deprecated, authors should use the Level 3+ double-colon syntax for these pseudo-elements.