CSS :link Pseudo-Class
The :link pseudo-class in CSS targets unvisited links (<a> elements with an href attribute). It allows you to style links before they are clicked.
1. Syntax
| Value | Description |
|---|---|
:link | Styles an unvisited link. |
✅ Important: The :link pseudo-class only applies to links that have not been visited.
2. Basic Example – Styling Unvisited Links
✅ All unvisited links will appear blue and without an underline.
3. Example – Changing Styles for Different Link States
✅ The link:
-
Blue (unvisited)
-
Purple (visited)
-
Red (hover)
-
Green (active)
4. Best Practices for Link Styling
✔ Use :link and :visited before :hover and :active.
✔ Combine with text-decoration: none; to remove underlines.
✔ Use :hover for user-friendly interactivity.
5. When to Use :link?
-
To differentiate unvisited links.
-
When styling navigation menus or buttons.
-
When you need strict control over link appearance.

