CSS Tutorial

Introduction

Edit Template

CSS Tutorial

Introduction

Edit Template

CSS Links

Links (<a> tags) are an essential part of any website, used for navigation and redirection. With CSS, you can control how links appear in different states: normal, hovered, visited, and active.

Syntax

				
					a {
    /* normal link styling */
}

a:hover {
    /* when user hovers over the link */
}

a:visited {
    /* already clicked/visited link */
}

a:active {
    /* when link is being clicked */
}

				
			

Styled Link with Hover Effect

				
					<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        a {
            color: blue;
            text-decoration: none;
            font-size: 18px;
            font-family: Arial;
        }

        a:hover {
            color: hotpink;
            text-decoration: underline;
        }

        a:visited {
            color: purple;
        }

        a:active {
            color: red;
        }
    </style>
</head>
<body>

    <h2>Learn With Arshyan</h2>
    <p>Visit our Tutorials page:</p>
    <a href="https://learnwitharshyan.com/tutorials" target="_blank">Go to Tutorials</a>

</body>
</html>

				
			

Explanation

  • color: blue; – Link appears blue by default.

  • text-decoration: none; – Removes underline on normal state.

  • :hover – When the mouse hovers over the link, it turns hotpink and underlined.

  • :visited – Visited links turn purple.

  • :active – When clicked, link briefly turns red.

  • target="_blank" – Opens the link in a new tab.

Try It Yourself

Replace the link with any URL you like, and test how each state (hover, visited, active) behaves.

Scroll to Top