Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

a tag without line-decoration in Bootstrap 4

I would like to have a link that looks just like plain text except for the cursor by using as few css as possible.

The problem: <a> has a blue color (that darkens when hovered) and also has underline on hover. I want it to look like plain text (black without underline).

By using the Bootstrap class "text-dark" I managed to get rid of the blue color. But how do I get rid of the underline (text-decoration) without writing css?

.no-underline:hover {
  text-decoration: none;
  
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">


<span>Standard text</sapn>
<hr>
<a href="#">Standard a tag. Different colors and underline on hover</a>
<hr>
<a href="#" class="text-dark">a tag with text-dark class. Note underline on hover</a>
<hr>
<a href="#" class="text-dark no-underline">a tag with text-dark class and css to disable underline on hover</a>
like image 803
Poogy Avatar asked Apr 03 '18 15:04

Poogy


People also ask

How do I remove a style from a tag?

To remove an attribute from each tag using jQuery, use the removeAttr() method and use the Universal Selector. Let us see how to use the method to remove all style attribute. Use the universal selector also to select all the elements.

How do I remove the underline from a tag in bootstrap?

By setting the text-decoration to none to remove the underline from anchor tag. Syntax: text-decoration: none; Example 1: This example sets the text-decoration property to none.

How do you remove the underline from a tag?

Complete HTML/CSS Course 2022 To remove underline from a link in HTML, use the CSS property text-decoration. Use it with the style attribute. The style attribute specifies an inline style for an element. Use the style attribute with the CSS property text-decoration to remove underline from a link in HTML.


2 Answers

Bootstrap 4 has the class "text-decoration-none"

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

https://getbootstrap.com/docs/4.3/utilities/text/#text-decoration

like image 89
Leon Avatar answered Oct 02 '22 17:10

Leon


There are several Bootstrap 4 classes that set text-decoration: none. Without knowing the semantic context of the link, I suggest you use the .btn class...

<a href="#" class="text-dark btn">a tag with text-dark class and css to disable underline on hover</a>

https://www.codeply.com/go/CIt6zI0Iqw

However, there may be a class that works better semantically such as nav-link (inside nav), card-link (inside cards), or .breadcrumb-item. Also, note that Bootstrap 4 only applies the underline to anchor links with the href="" attribute. A simple anchor anchor will not have an underline on hover.

like image 44
Zim Avatar answered Oct 02 '22 16:10

Zim