Removing Dotted Line around Active Links using CSS

We can remove the default behavior of hyperlinks which is to show a dotted outline around themselves when active or focused by declaring CSS outline property on active/focused links to be none.

Syntax

a, a:active, a:focus {
    outline: none;
}

Example

Let's see how to remove dotted line around active links with an example −

<!DOCTYPE html>
<html>
<head>
    <title>Remove dotted line around links using css</title>
    <style>
        div {
            color: #000;
            padding: 20px;
            background-image: linear-gradient(135deg, #dc3545 0%, #9599E2 100%);
            text-align: center;
            margin: 20px;
            border-radius: 10px;
        }
        
        a {
            color: white;
            text-decoration: none;
            font-size: 18px;
            padding: 10px 20px;
            background-color: rgba(0,0,0,0.3);
            border-radius: 5px;
            display: inline-block;
        }
        
        /* Remove dotted outline from links */
        a, a:active, a:focus {
            outline: none;
        }
        
        a:hover {
            background-color: rgba(0,0,0,0.5);
        }
    </style>
</head>
<body>
    <div>
        <h1>HTML Links Demo</h1>
        <a href="https://google.com" target="_blank">Go To Google</a>
        <br><br>
        <a href="/html/index.htm">HTML Tutorial</a>
    </div>
</body>
</html>
A gradient background container appears with white styled links. When you click or tab to focus on the links, no dotted outline appears around them due to the outline: none property.

Alternative Method: Using Transparent Outline

Instead of completely removing the outline, you can make it transparent to maintain accessibility while hiding the visual effect −

<!DOCTYPE html>
<html>
<head>
    <style>
        .container {
            padding: 30px;
            text-align: center;
        }
        
        .link {
            color: #007bff;
            text-decoration: underline;
            margin: 10px;
            font-size: 16px;
        }
        
        /* Make outline transparent instead of none */
        .link, .link:active, .link:focus {
            outline: 1px solid transparent;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>Links with Transparent Outline</h2>
        <a href="#" class="link">Sample Link 1</a>
        <br><br>
        <a href="#" class="link">Sample Link 2</a>
    </div>
</body>
</html>
Blue underlined links appear without any visible dotted outline when clicked or focused, but still maintain accessibility structure.

Conclusion

The outline: none property effectively removes dotted outlines from active links. However, consider using outline: transparent instead to maintain accessibility for keyboard navigation users.

Updated on: 2026-03-15T14:04:19+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements