OneBite.Dev - Coding blog in a bite size

remove underline from link css

Code snippet for how to remove underline from link css with sample and detail explanation

Underlining links has been a staple of web design since its inception because it makes links stand out. However, sometimes you might prefer a cleaner look. If you feel that unlined links better suit your web page design, CSS provides a simple way to remove these underlines.

Here is a simple code snippet to remove the underline from hyperlinks:

a {
  text-decoration: none;
}

In the given code, ‘a’ is a CSS selector that selects all the hyperlinks on your webpage. Text-decoration is a property that is used to specify the decoration added to the text.

The code:

a {
  text-decoration: none;
}

indicates that all the hyperlinks should not have any text decoration. The value ‘none’ removes the underline from all the links.

This code snippet represents a webpage-wide rule. If you wish to apply this only to certain links, you may use class or id selectors.

For example, if we want to remove underline from links with a class name ‘no-underline’, the CSS would be:

.no-underline {
  text-decoration: none;
}

Now, only links with a class of ‘no-underline’ will have no underline.

Here’s how to use it in your HTML code:

<a href="http://example.com" class="no-underline">This link won't be underlined</a>

This way you can customize which links on your page should be underlined and which should not.

Remember, it is possible to add the underline back by simply replacing ‘none’ with ‘underline’ in the ‘text-decoration’ property. So modifying the look of your links is completely within your control using simple CSS tricks.

css