Role of CSS :link Selector

The CSS :link selector is a pseudo-class used to style all unvisited links on a webpage. It targets anchor elements (<a>) that have an href attribute and have not been visited by the user yet.

Syntax

a:link {
    property: value;
}

Example

The following example demonstrates how to use the :link selector to style unvisited links with an orange background color −

<!DOCTYPE html>
<html>
<head>
<style>
    a:link {
        background-color: orange;
        color: white;
        padding: 8px 16px;
        text-decoration: none;
        border-radius: 4px;
    }
</style>
</head>
<body>
    <a href="https://www.example.com">Demo Website</a>
    <br><br>
    <a href="https://www.tutorialspoint.com">TutorialsPoint</a>
</body>
</html>
Two orange buttons with white text appear on the page: "Demo Website" and "TutorialsPoint". The links have padding and rounded corners with no underline decoration.

Link States

The :link selector works alongside other link pseudo-classes to provide complete link styling −

Pseudo-class Description
:link Unvisited links
:visited Visited links
:hover Links when mouse hovers over them
:active Links when being clicked

Conclusion

The :link pseudo-class is essential for styling unvisited links. It's commonly used with other link states to create a complete link styling experience for better user interaction.

Updated on: 2026-03-15T12:20:58+05:30

277 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements