CSS Links - Detailed Overview

Introduction to CSS Links

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.

Styling Normal Links

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;
}

This is a styled link

Styling Visited Links

Visited links are those that the user has already clicked. You can style them differently using the :visited pseudo-class:

a:visited {
    color: #5a5a5a;
}

This link is visited

Styling Hover Links

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;
}

Hover over this link to see the effect

Styling Active Links

The :active pseudo-class styles a link when it is being clicked:

a:active {
    color: #ff0000;
}

Click on this link to see the active state

Combining Link States

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;
}

See all link states in action