Skip to content
techsnow

CSS Selectors

Pseudo-elements

A pseudo-element styles a specific part of an element. It starts with two colons.

Pseudo-elementStyles
::beforeInserts content before the element's content
::afterInserts content after it
::first-letterThe first letter
::first-lineThe first line
::placeholderPlaceholder text of an input
::selectionText the user has highlighted
.required::after { content: " *"; color: red; }
p::first-letter { font-size: 2em; font-weight: bold; }
::selection { background: gold; }
input::placeholder { color: #999; }