Home  >  Article  >  Web Front-end  >  What are the functions of the pseudo elements "::after" and "::before"?

What are the functions of the pseudo elements "::after" and "::before"?

王林
王林forward
2020-07-11 17:17:364006browse

What are the functions of the pseudo elements

:before and :after are two new pseudo-elements that appeared in CSS2.1.

(Recommended tutorial: css Quick Start)

At first, the prefix of pseudo-elements used single colon syntax, but with the evolution of the Web, in the CSS3 specification Here, a single colon represents a pseudo-class, and the syntax of a pseudo-element is modified to use a double colon, becoming ::before ::after. Pseudo elements do not exist in the dom, only in the page.

Function:

::after is used to create a pseudo element as the last child element of the selected element. Usually, the content attribute is used to add decorative content to the element. This virtual element is an inline element by default.

::before Creates a pseudo-element that will be the first child of the matching selected element.

The above is the detailed content of What are the functions of the pseudo elements "::after" and "::before"?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete