Search code examples
htmlcsshref

Disable div class for <a> to style the <a>


I have this code that styles the <a href="#">:

<div class="styled">
    <a href="#">link</a>
    <div class="notStyled">
        <a href="#">another link</a>
    </div>
</div>

The first link have one style and the second link have the same style, I want it to be default like a clean link.


Solution

  • Here, try this JSFiddle example,

    .styled > a {
      color:black;
    }
    

    The > used in this means it only selects direct children of .styled and not ALL children.

    What you are probably doing is .styled a, which selects all children (even nested within others), and you don't want to do that...