Pseudo-class

A CSS pseudo-class targets elements in a particular state, written with a single colon, like :hover or :focus. It lets you style how elements look when users interact with them.

Web

Common pseudo-classes include :hover (mouse over), :focus (keyboard focus), :active (being clicked), :first-child, and :nth-child(). They are essential for interactive feedback.

Pseudo-classes describe a state, while pseudo-elements (written with ::) style a specific part of an element.

Examples

CSS

a:hover {
  color: red;
  text-decoration: underline;
}

Output:

Turns links red and underlined when the mouse hovers over them.

Learn it in a lesson

See also

Back to the Dictionary