How to remove underline from links in bootstrap.


In this article, we will learn how to remove the underline from links in bootstrap.

Just like any other HTML element, links can also be styled using CSS. We can change it color and size and even its text decoration.

A link in HTML generally means hyperlinks which is created using the <a> tag. It helps us to navigate through pages.

The <a> tag have four different pseudo-classes

  1. a:link
  2. a:visited
  3. a:hover, and
  4. a:active

Now, by default, the underline will appear beneath all of the links and their pseudo-classes too.

To remove this underline from the link, we can just change the text-decoration property of the <a> tag in our CSS.

a{
    text-decoration: none;
}

If you want to remove the underline from pseudo-classes too, then

a:link, a:visited, a:hover, a:active{
    text-decoration: none;
}

Now, this CSS property will remove the underline from links on your web page.

In bootstrap, we can remove the underline from the links in two ways:

  1. Using CSS text-decoration property, and
  2. Using the bootstrap class : .text-decoration-none

In bootstrap, by default, links don't show underline beneath it, even when you visit the link.

The underline is only visible when you hover over it or it's in active state, meaning when you move your cursor over it and click the link.

So to remove the underline from links in bootstrap we can set the text-decoration property of a:hover and a:active to none.

a:hover, a:active{
    text-decoration: none;
}

Another way is to use the bootstrap class text-decoration-none. It is a very easy way to remove the underline from the hyperlinks. Just add the class to the <a> tag.

<a class="text-decoration-none" href="#">
    No underline link
</a>

Now the link will not show any underline beneath it.

Conclusion:

If you want to remove the underline from all the links on your website, it's better to go with the CSS styling way. The Bootstrap class method is good if you have some particular links where you don't want the underline.


💾 Recommended Articles