By Hemanta Sundaray on 2021-06-22
A link can exist in any one of the following five states.
Link
Visited
Hover
Focus
Active
The following example illustrates the default behavior of links.
<p><a href="”#”">A Link</a></p>
P {
margin: 1rem;
font-size: 3rem;
text-align: center;
}
We have the following result:
By default, links, depending on their state, have the following default styles.
Unvisited links are blue and underlined, as you can see above. Also, hovering over a link changes the mouse pointer to a little hand icon.
Now, click on the link, you will see that the color has changed to purple.
Now click and hold, the link color turns red. Active links are red by default.
Next, keep pressing the tab key until the link is in focus. You will see an outline around the link.
Links are styled using the following order:
a {
}
a:link {
}
a:visited {
}
a:focus {
}
a:hover {
}
a:active {
}
The order in which you style the links is important because the styles in the first rule will apply to all the subsequent ones.