Links Using CSS

CSS allows you to define the properties differently depending on whether the link is unvisited, visited, active, or whether the cursor is on the link. This makes it possible to add fancy and useful effects to your website.

To control these effects, you use pseudo-classes. A pseudo-class allows you to take into account different conditions or events when defining a property for an HTML tag.

a {
color: blue;
}

A link can have different states. For example, it can be visited ,or not visited. You can use pseudo-classes to assign different styles to visited and unvisited links.

a:link {
color: blue;
}
a:visited {
color: red;
}

Use a:link and a:visited for unvisited and visited links respectively. Links that are active have the pseudo-class a:active and a:hover is when the cursor is on the link.

Remove Underline of Links

To remove underlining, simply set the value of text-decoration to none.

a {
text-decoration: none;
}