Remove blue underline from link
Solution 1
You are not applying text-decoration: none;
to an anchor (.boxhead a
) but to a span element (.boxhead
).
Try this:
.boxhead a {
color: #FFFFFF;
text-decoration: none;
}
Solution 2
The anchor tag (link) also has pseudo-classes such as visited, hover, link and active. Make sure your style is applied to the state(s) in question and that no other styles are conflicting.
For example:
a:hover, a:visited, a:link, a:active
{
text-decoration: none;
}
See W3.org for more information on user action pseudo-classes :hover, :active, and :focus.
Solution 3
text-decoration: none !important
should remove it .. Are you sure there isn't a border-bottom: 1px solid
lurking about? (Trace the computed style in Firebug/F12 in IE)
Solution 4
Just add this attribute to your anchor tag
style="text-decoration:none;"
Example:
<a href="page.html" style="text-decoration:none;"></a>
Or use the CSS way.
.classname a {
color: #FFFFFF;
text-decoration: none;
}
Solution 5
Sometimes what you're seeing is a box shadow, not a text underline.
Try this (using whatever CSS selectors are appropriate for you):
a:hover, a:visited, a:link, a:active {
text-decoration: none!important;
-webkit-box-shadow: none!important;
box-shadow: none!important;
}
dmr
Updated on July 16, 2022Comments
-
dmr almost 2 years
I am attempting to have a link show up in white, without an underline. The text color shows up correctly as white, but the blue underline is stubbornly persisting. I tried
text-decoration: none;
andtext-decoration: none !important;
in the CSS to remove the link underline. Neither worked..boxhead .otherPage { color: #FFFFFF; text-decoration: none; }
<div class="boxhead"> <h2> <span class="thisPage">Current Page</span> <a href="myLink"><span class="otherPage">Different Page</span></a> </h2> </div>
How can I remove the blue underline from the link?
-
Davor Lucic about 14 yearsWell it should go away when you do text-decoration:none. Are you sure you are appling this to the right element? Can you provide example code?
-
shuttle87 about 14 yearsWhere is text-decoration: none being used?
-
-
artlung about 14 yearsI think you mean
a:link
when you saya:click
-
JMTyler almost 14 yearsBut what if you have text surrounding the span as well, and you want the surrounding text to have the link underline, but the text within the span to have none?
-
Davor Lucic almost 14 years@JMTyler you can't have partial underlines like that, but I guess you could apply border on text inside of span.
-
JMTyler almost 14 yearsWould it make a difference if it is a div? And how exactly would applying a border cause the underline to appear gone?
-
Tony Topper over 12 years@rebus, You can't? Why not? Cause in at least IE7+ and FireFox 4+ you can, but not in Chrome for some reason. Here's the code I got to work in the non-Chrome browsers I tested:
.toc-list a > span{text-decoration:none !important;}
I think @JMTyler's question is legitimate; I am searching for the same solution. -
Aysennoussi over 9 yearsTwitter did the same with the message page you can see that the name has underline but not the tag
-
Doresoom over 8 yearsThis should be the actual accepted answer, as I was having the same problem AFTER clicking on my button link. The visited property was still changing to purple when I came back to the page.
-
Partly Cloudy over 7 yearsIt appears
text-decoration
doesn't support overriding on nested tags, as hinted above. Once you have ana { text-decoration: underline; }
rule applied you cannot de-apply it eg witha .wish_this_were_not_underlined { text-decoration: none; }
. I can't find a reference for this but that's my experience (in Chrome). -
Bhargav over 6 yearsThis one should be the answer.. Sometimes, box shadow gives an underline affect.
-
Ryan Burbidge over 6 yearsLike others above I was not able to de-underline the text by applying
text-decoration: none;
so instead we chose to hide the line usingtext-decoration: underline; text-decoration-color: white;
. /hack -
agentofuser almost 6 yearsSetting
border-bottom-style: none;
fixed it for me. -
Magnus Bull over 5 yearsBetter yet, try
.hidden-underline { text-decoration-color: #00000000; }
to set the underline color to transparent (0 alpha). Mind, it is not widely supported as of today (Edge, looking at you). -
Asuquo12 almost 5 yearsmake sure its on the anchor tag and inline could be better since you might want the underline on other links.
-
Patrick Denny over 4 yearsif you're only trying to remove the underline from an element inside an anchor, and not the entire anchor. you need to make the inner element an inline-block like so:
.boxhead .otherPage { display: inline-block; color: #FFFFFF; text-decoration: none; }
-
Ajowi about 4 yearsIt is an answer, but not the best. The scope of those are global and not specific. Something like this should do the trick:
.otherPage a:link {text-decoration:none;}
; repeat that for visited, active and hover if needed. -
snarf almost 4 years