Search⌘ K
AI Features

Link and URL Pseudo-Classes

Explore how to style hyperlinks dynamically using CSS pseudo-classes such as :link, :visited, :hover, :active, and :target. Learn to enhance user interaction by differentiating link states and highlighting elements targeted by URL fragments, improving site navigation and user experience.

Link and URL pseudo-classes allow us to style hyperlinks based on their state, such as whether they've been visited or are currently active. They also enable us to style elements targeted by URL fragments.

:link and :visited

The :link applies to unvisited links, while the :visited applies to links the user has already visited.

The above CSS code styles unvisited links in blue, while styles the visited links in gray.

:hover, :active, and :focus on links

These pseudo-classes hover, active, and focus ...