CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2012

    Selector problem

    I'm breaking my head with this simple problem. I know its not a bug nor a cross browser issue, tested on firefox and internet explorer. Simply I don't understand why its resolving this way.

    This are the css rules:

    .division a { color: red; }
    .links a {color: blue;}

    This is the html code

    <div class="division">
    <a class="links" href="">Somesite</a>

    In my humble opinion both rules have the same specificity but I expected the link to show in BLUE because the second rule is closer, but the link is shown in RED

    Any idea what is my assuming wrong, How to make this code work. I want to use a class for the links, not an id. I also want to be able to style the link states.

    Really appreciate the help. Thanks in advance.

  2. #2
    Join Date
    Jun 2009

    Post Re: Selector problem

    I think the problem is the CSS definition as it's not quite right. What you've entered is:
    .division a { color: red; }
    .links a {color: blue;}
    Which is creating a class called division with a red color which is also applied to <A> tags. It's also creating a class called links which is blue and which is also applied to <A> tags, however they are already styled.
    The correct way to phrase the styles should be something like:
    div.division { color: red; }
    a.links {color: blue;}
    Which creates a class called division that applies red to <DIV> tags, and a class called links that applies blue to <A> tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width