Biker John
Biker John

Reputation: 2711

CSS - linked div affects children

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

Upvotes: 0

Views: 79

Answers (1)

Madara&#39;s Ghost
Madara&#39;s Ghost

Reputation: 175007

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.

Upvotes: 2

Related Questions