45

Totally baffled! I've tried rewriting the text-decoration: none line several different ways. I also managed to re-size the text by targeting it but the text-decoration: none code will not take.

Help much appreciated.

Code

.widget    
{
     height: 320px;
     width: 220px;
     background-color: #e6e6e6;
     position: relative;                              
     overflow: hidden;                          
}


.title    
{
     font-family: Georgia, Times New Roman, serif;
     font-size: 12px;
     color: #E6E6E6;
     text-align: center;
     letter-spacing: 1px;
     text-transform: uppercase;
     background-color: #4D4D4D;    
     position: absolute;
     top: 0;
     padding: 5px;
     width: 100%;
     margin-bottom: 1px;
     height: 28px;
     text-decoration: none;
}

a .title    
{
     text-decoration: none;
}
<a href="#">
    <div class="widget">  
        <div class="title">Underlined. Why?</div>  
    </div>
</a>
Solomon Ucko
  • 2,682
  • 2
  • 14
  • 27
Olly F
  • 2,569
  • 9
  • 28
  • 34

14 Answers14

44
a:link{
  text-decoration: none!important;
}

=> Working with me :) , good luck

DongNguyen
  • 568
  • 4
  • 6
  • 2
    very cool, thanks! And btw, when I need to underline for hover, the same solution worked - **.some_title:hover { text-decoration: underline!important; }** – Gene Bo Jun 18 '15 at 03:50
43

You have a block element (div) inside an inline element (a). This works in HTML 5, but not HTML 4. Thus also only browsers that actually support HTML 5.

When browsers encounter invalid markup, they will try to fix it, but different browsers will do that in different ways, so the result varies. Some browsers will move the block element outside the inline element, some will ignore it.

Guffa
  • 640,220
  • 96
  • 678
  • 956
9

Use CSS Pseudo-classes and give your tag a class, for example:

<a class="noDecoration" href="#">

and add this to your stylesheet:

.noDecoration, a:link, a:visited {
    text-decoration: none;
}
Mimeshead
  • 169
  • 1
  • 8
6

Add this statement on your header tag:

<style>
a:link{
  text-decoration: none!important;
  cursor: pointer;
}
</style>
Ram Madhavan
  • 2,166
  • 1
  • 15
  • 20
3

Try placing your text-decoration: none; on your a:hover css.

2

I have an answer:

<a href="#">
    <div class="widget">  
        <div class="title" style="text-decoration: none;">Underlined. Why?</div>  
    </div>
</a>​

It works.

RichardBernards
  • 3,140
  • 1
  • 20
  • 30
jnhy
  • 21
  • 1
2

Add a specific class for all the links :

html :

<a class="class1 class2 noDecoration"> text </a>

in css :

.noDecoration {
  text-decoration: none;
}
Alouani Younes
  • 668
  • 8
  • 14
2

if you want a nav bar do

ul{ list-style-type: none; } li{text-decoration: none;
  • This will make it want to make the style of the list type to None or nothing

with the < a > tag:

a:link {text-decoration: none}
1

There are no underline even I deleted 'text-decoration: none;' from your code. But I had a similar experience.

Then I added a Code

a{
 text-decoration: none;
}

and

a:hover{
 text-decoration: none;
}

So, try your code with :hover.

1

I had lots of headache when I tried to customize a WordPress theme and the text-decoration didn't help me. In my case I had to remove the box-shadow as well.

a:hover {
    text-decoration: none;
    box-shadow: none;
} 
Zoltan Febert
  • 181
  • 2
  • 6
0

try adding this to your stylesheet:

a {text-decoration:none;}
Losbear
  • 2,939
  • 29
  • 28
0

I used the code below to get mine to work in Chrome. You can adjust the nesting:

a:-webkit-any-link { color: black; }
MikeT
  • 32,107
  • 13
  • 38
  • 54
Eben Hafkamp
  • 109
  • 1
  • 1
  • 10
0

As a sidenote, have in mind that in other cases a codebase might use a border-bottom css attribute, for example border-bottom: 1px;, that creates an effect very similar to the text-decoration: underline. In that case make sure that you set it to none, border-bottom: none;

dimyG
  • 557
  • 5
  • 16
-7

I just did it the old way i know that its not right but its a quick fix.

<h1><a href="#"><font color="#FFF">LINK</font></a></h1>