Links in HTML can be styled using CSS. You can control the appearance of links in different states such as normal, visited, hover, and active.
By default, links are styled with a blue color and underline. You can customize these styles using CSS. For example:
a {
color: #007BFF;
text-decoration: none;
}
Visited links are those that the user has already clicked. You can style them differently using the :visited
pseudo-class:
a:visited {
color: #5a5a5a;
}
The :hover
pseudo-class allows you to define styles for when the user hovers over a link with their mouse:
a:hover {
text-decoration: underline;
}
The :active
pseudo-class styles a link when it is being clicked:
a:active {
color: #ff0000;
}
You can combine different link states to create comprehensive styles. Here’s an example that includes all link states:
a {
color: #007BFF;
text-decoration: none;
}
a:visited {
color: #5a5a5a;
}
a:hover {
text-decoration: underline;
}
a:active {
color: #ff0000;
}