Navigating Pseudo-Element Notation in Web Development
Many browsers, including IE7 and IE8, have limited support for double-colon notation for pseudo-elements like ::after. Modern browsers support single-colon notation (:after) for backwards compatibility. This raises the question of whether to use single-colon notation exclusively and later update code when IE8's market share dwindles.
Single vs. Double-Colon Notation
Using both notations together is not recommended. CSS 2.1-compliant user agents will ignore the entire rule if the selector cannot be parsed.
.foo:after, .foo::after { /*styles*/ }
Recommendation
For the immediate future, it's best to stick with single-colon notation (:after) for pseudo-elements. It is more concise and widely supported. As IE8's market share becomes negligible, consider revisiting code to use double-colon notation for better specificity.
The above is the detailed content of Single or Double Colon Notation for Pseudo-elements: What's the Best Approach?. For more information, please follow other related articles on the PHP Chinese website!