What is the difference between CSS pseudo-elements and pseudo-classes
This article mainly introduces the difference between CSS pseudo-elements and pseudo-classes is what the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, with a certain reference value, I believe that you read this CSS pseudo-elements and pseudo-class differences are what the article will have a harvest, let's take a look at it.
The difference between pseudo-elements and pseudo-classes
Please pay attention to the double colon representation -:: first-line contrast: first-line
In CSS3, double colons replace the single colon representation of pseudo elements. This is an attempt by the W3C to distinguish between pseudo classes and pseudo elements.
In CSS2 and CSS1, pseudo-classes and pseudo-elements both use single colon syntax.
For backward compatibility, CSS2 and CSS1 pseudo elements accept single colon syntax.
In other words, there is not much difference between pseudo-elements and pseudo-classes.
It's just an attempt by the W3C to distinguish between pseudo classes and pseudo elements.
You can achieve the same effect by using both odd and double colons!
Add a special state to the first word
You can use the pseudo element [:: first-letter] to add special effects to the first character of the text!
P::first-letter {
Color: red
Font-size: 18px
}
This is the end of the article on "what's the difference between CSS pseudo-elements and pseudo-classes". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "what is the difference between CSS pseudo elements and pseudo classes". If you want to learn more knowledge, you are welcome to follow the industry information channel.