0

Is there a way that "a" does not affect texts inside the div? Just the div itself? I dont want them to be underlined. And no, i cant change "a"'s text-decoration to none, because i need it for regular links.

<a href="#">
<div style="smthing">
<span>text</span>
<span>text</span>
<span>text</span>
<span>text</span>
</div>
</a>

thanks

Biker John
  • 2,621
  • 10
  • 33
  • 52

1 Answers1

2

Yes, use the direct child selector >

a > div { styles: go here; }

It will only affect "the div element which is a direct child of a element"

Note that some properties have inherit as a value by default. Those properties will need to be overridden.

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
  • By the way, remember that an 'a' wrapping a 'div' is not valid unless you adopt an html5 doctype. – Tilt Feb 12 '12 at 12:44
  • [It's simply called the "child selector".](http://stackoverflow.com/a/3225905/106224) Also note that some properties cannot be overridden in descendant elements either. `text-decoration`, as mentioned in the question, is one of those properties. – BoltClock Feb 12 '12 at 13:55