➢A CSS pseudo-element is used to style specified parts of an element.
➢Example
➢Style the first letter, or line, of an element
➢Insert content before, or after, the content of an element
➢The ::first-line pseudo-element is used to add a special style to the first line of a text.
EXAMPLE:
p::first-line {
color: #ff0000;
font-variant: small-caps;
}
➢The ::first-letter pseudo-element is used to add a special style to the first letter of a text.
EXAMPLE:
p.intro::first-letter {
color: #ff0000;
font-size: 200%;
}
➢Several pseudo-elements can also be combined.
EXAMPLE:
p::first-letter {
color: #ff0000;
font-size: xx-large;
}
p::first-line {
color: #0000ff;
font-variant: small-caps;
}
➢The ::before pseudo-element can be used to insert some content before the content of an element.
EXAMPLE:
h1::before {
content: url(smiley.gif);
}
➢The ::after pseudo-element can be used to insert some content after the content of an element.
EXAMPLE:
h1::after {
content: url(smiley.gif);
}
➢The ::marker pseudo-element selects the markers of list items.
EXAMPLE:
::marker {
color: red;
font-size: 23px;
}
➢The ::selection pseudo-element matches the portion of an element that is selected by a user.
➢The following CSS properties can be applied to ::selection: color, background, cursor, and outline.
EXAMPLE:
::selection {
color: red;
background: yellow;
}