OneBite.Dev - Coding blog in a bite size

get rid of link underline css

Code snippet for how to get rid of link underline css with sample and detail explanation

Underlining links is a conventional method to distinguish clickable text on a webpage. However, for aesthetic purposes, you might want to remove the underline. This article gives you a stepwise explanation of how to get rid of link underline using CSS.

a {
    text-decoration: none;
}

The whole concept of getting rid of the underline from hyperlinks in CSS revolves around the ‘text-decoration’ property. This property is used in modifying the appearances of decorative lines on text. It’s like a master switch for controlling text decorations.

a - The Selector:

In our code snippet, ‘a’ is the selector. Basically, the selector chooses the HTML elements that you want to style. Here, ‘a’ signifies all hyperlinks on your webpage.

{ … } - The Declaration Block:

This is a declaration block, denoted by curly braces { }. All declarations are made inside this block.

text-decoration - The Property:

‘text-decoration’ is the property you’re manipulating here. As mentioned before, this property is used to set the text formatting to the links (underlined, overline, line-through).

none - The Value:

‘none’ is the value set for our chosen property i.e., ‘text-decoration’. There are other values that you can use too (like underline, overline, line-through), but here we’re using ‘none’ which effectively removes all text decorations - in our case, it removes the underline from all hyperlinks.

By adding the code snippet provided to your CSS, all of the links on your webpage will have no underlines. This makes your webpage look cleaner and more customized, taking another step in the direction of perfecting your webpage aesthetics.

css