Home > Web Front-end > CSS Tutorial > What is the function of pseudo elements in css

What is the function of pseudo elements in css

王林
Release: 2020-07-20 17:20:24
forward
4051 people have browsed it

What is the function of pseudo elements in css

Pseudo elements can be used to add some special effects to selectors.

(Recommended tutorial: css quick start)

Grammar:

selector:pseudo-element {property:value;}
Copy after login

Example:

1, "first-line" Pseudo elements are used to set special styles to the first line of text.

In the following code, the browser will format the first line of text of the p element according to the style in the "first-line" pseudo-element:

p:first-line {
    color:#ff0000;    
    font-variant:small-caps;
    }
Copy after login

Note: "first-line" Pseudo-elements can only be used with block-level elements.

2. The "first-letter" pseudo-element is used to set a special style to the first letter of text:

p:first-letter {
    color:#ff0000;    
    font-size:xx-large;
    }
Copy after login

The above is the detailed content of What is the function of pseudo elements in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template