Pseudo-classes and pseudo-elements are independent of the document structure. The way they get the elements is not based on the element characteristics of the ID, class, attribute, but on the element that is in a special state (pseudo-Class), or the element's special content (pseudo-element). The difference is summarized as follows:
① does not have the same wording:
css3
To differentiate between the two, the pseudo-class is explicitly represented by a colon, and the pseudo-element is represented by two colons.
:Pseudo-classes::Pseudo-elements
The ② function is not the same:
CSS
Pseudo-Class (pseudo-classes): Used to add special effects to certain selectors, that is, to add special effects (usually dynamic effects) on the basis of the current static style of the element . So when an element reaches a certain state, it may get a pseudo-class style, and when the state changes, it loses the style.
Property |
Describe |
: Active |
Add a style to the element that is activated |
: Focus |
Add a style to an element that has keyboard input focus |
: hover |
Add a style to an element when the mouse hovers over the element |
: Link |
Add a style to a link that is not visited |
: Visited |
Add a style to a link that has been visited |
: First-child |
Add a style to the first child element of an element |
: lang |
Add a style to an element with the specified Lang property |
remark: In the CSS definition, the same element: hover must be in: Link,: Visited before it takes effect: active must be in: hover before it takes effect.
CSS Pseudo-elements (pseudo-elements): Used to set special effects to certain selectors, is to set and manipulate specific content in the element , the operation level is deeper than pseudo-class, so the dynamic is worse than pseudo-class.
|
description |
:first-letter |
add a special style to the first letter of the text |
:first-line |
add a special style to the first line of text |
:before |
add content before element |
:after |
add content after element |
CSS Properties-the difference between pseudo-classes and pseudo-elements