Because pseudo-elements "Pseudo-elements" are not real HTML elements, but a special selector in CSS that is used to insert content or style at a certain position of the element. Pseudo-elements are a very Useful CSS selectors can help developers achieve some special effects and layouts, making web pages richer and more diverse.
# Operating system for this tutorial: Windows 10 system, Dell G3 computer.
Pseudo-elements (Pseudo-elements) are a special selector in CSS, used to insert content or style at a certain position of the element. They are called "pseudo-elements" because they are not real HTML elements, but virtual elements created somewhere within an existing element.
The syntax of pseudo elements is represented by double colons (::), such as::before, ::after, etc. In earlier versions of CSS, the syntax of pseudo-elements was represented by a single colon (:), such as: before, :after, etc.
The function of pseudo-element is to add content before or after the element, and the content does not need to exist in the HTML document. By setting the content attribute of the pseudo element, you can insert some text or icons.
In addition, pseudo elements can also be used to set the style of elements, such as setting the background, border, text color, etc. of the element. The style of a pseudo element will act on a certain position of the element. Pseudo elements are usually used to achieve some special effects, such as adding an arrow in front of the element, adding a shadow behind the element, etc.
In short, pseudo elements are a very useful CSS selector that can help developers achieve some special effects and layouts to make web pages richer and more diverse.
The above is the detailed content of Why are pseudo elements called pseudo elements?. For more information, please follow other related articles on the PHP Chinese website!