JavaScript Development Space

Using the CSS :link Pseudo-Class

The :link pseudo-class in CSS is used to style links that have not yet been visited by the user. It specifically targets anchor (<a>) elements that have an href attribute, but which the browser considers "unvisited."

Example Usage:

css
1 a:link {
2 color: blue; /* Unvisited link color */
3 text-decoration: none; /* Remove underline */
4 }

How It Works:

  • Targeting Unvisited Links: The :link pseudo-class applies styles to links that the user has not clicked or visited. After visiting, the :visited pseudo-class is used instead.
  • Order of Pseudo-Classes: When using multiple pseudo-classes (like :hover, :active, and :visited), CSS has a recommended order for link styling:
    • :link (unvisited link)
    • :visited (visited link)
    • :hover (when the link is hovered over)
    • :active (when the link is being clicked)

Example with multiple pseudo-classes:

css
1 a:link {
2 color: blue;
3 }
4
5 a:visited {
6 color: purple;
7 }
8
9 a:hover {
10 color: red;
11 }
12
13 a:active {
14 color: green;
15 }

Important Notes:

  • The :link pseudo-class only applies to anchor elements (<a>) with an href attribute.
  • Without href, links won’t be affected by :link or :visited

This allows you to style links consistently across your site while providing a clear visual difference between visited and unvisited links.

JavaScript Development Space

JSDev Space – Your go-to hub for JavaScript development. Explore expert guides, best practices, and the latest trends in web development, React, Node.js, and more. Stay ahead with cutting-edge tutorials, tools, and insights for modern JS developers. 🚀

Join our growing community of developers! Follow us on social media for updates, coding tips, and exclusive content. Stay connected and level up your JavaScript skills with us! 🔥

© 2025 JavaScript Development Space - Master JS and NodeJS. All rights reserved.