Open In App

CSS :link Selector

Last Updated : 29 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

The :link is used to target the unvisited link for styling not the links which is already visited. For styling on visited use “:visited“, for styling on click use “:active” and for styling move mouse on link use “:hover”.

Syntax:  

:link {
//property
}

Example: 

<!DOCTYPE html>
<html>
<head>
    <style>
        a:link {
            background-color: limegreen;
        }
    </style>
</head>
<body>
    <h3>Unvisited links.</h3>
    <a href="https://ide.geeksforgeeks.org/">Geeks for Geeks</a>
</body>
</html>

Output: 

Supported Browsers: 

  • Google Chrome 1.0
  • Edge 12.0
  • Firefox 1.0
  • Safari 1
  • Opera 3.5

CSS :link Selector – FAQs

What does the :link selector do in CSS?

The :link selector targets all unvisited links on a webpage, allowing you to style links that have not yet been clicked by the user.

How do I style unvisited links differently from visited ones?

Use the :link selector, like a:link { color: blue; }, to style all unvisited links, and combine it with :visited for visited links.

Can the :link selector be combined with other pseudo-classes?

Yes, :link can be combined with other pseudo-classes, such as :hover or :focus, for more specific styling.

Does the :link selector work with all elements?

No, the :link selector specifically targets anchor (<a>) elements with an href attribute that have not been visited.

Is the :link selector supported by all browsers?

Yes, the :link selector is supported by all modern browsers, including older versions.


Next Article

Similar Reads

three90RightbarBannerImg