1

I have a <div> inside a <a>, that I don't want to be underlined.

HTML :

<a href="/joomla17/contact">
  <div class="button">nous contacter</div>
</a>

A generic a rule is defined elsewhere.

I tried this with css :

.button {
    text-decoration: none;
}

but it is still underlined. Checked with Firebug that the text-decoration: none isn't overridden.

I feel that I have to specify a:link, but I don't know how to make it match my class

Joffrey Maheo
  • 2,919
  • 2
  • 20
  • 23
CharlesB
  • 86,532
  • 28
  • 194
  • 218

2 Answers2

2

Since you are using the div with display: inline;, its not necessary because a is an inline element by default. So why put an inline container inside an inline element?

<a class="button" href="/joomla17/contact">nous contacter</a>

But maybe you have some special reasons for that build, so this could be an solution with the div. Since the div is inside the a, it inherits the properties of a, so normally it should inherit the underline thing too. But maybe you need to set that on the div explicitly.

.button, .button div { text-decoration:none; }

Maybe you need to add !important in front of the ;, depends on the complexity of your layout.

Corubba
  • 2,229
  • 24
  • 30
0

Try

.button{text-decoration:none !important;}

to avoid that your style is overriden by any following rule.

If you want to use pseudo classes on your a-element it would look like this:

a:link{/* ... */} 
a:active{/* ... */} 
a:hover{/* ... */}
a:visited{/* ... */}

and if you want to access the div when the link has a specific state use

a:hover .button{/* ... */}

for instance.

Jay
  • 2,141
  • 6
  • 26
  • 37
  • Why do I get down voted? My answer is technically correct and as long as the asker doesn't provide any more details I can't see any reason why my answer isn't considered to be right. – Jay Jan 22 '12 at 00:57
  • I didn't downvote, but it didn't work, sorry but I can't tell you why – CharlesB Jan 22 '12 at 01:13
  • I think your solution does not work because of this: http://stackoverflow.com/a/18493630/143295 – Nicole Nov 04 '13 at 10:03