Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
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.
Advertisements
