1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Difference between 'a.Name' and '.Name A' ?

Discussion in 'CSS' started by just_a_w, Jan 3, 2006.

  1. #1
    What's the difference between the following declaractions?

    a.Content {
    background: #FFFFFF;
    }

    .Content A {
    background: #FFFFFF;
    }


    I've noticed that ".Content A" works when specifying a style for a table-data <td> tag but doesn't work for specifying a style for an HREF.
    On the other hand, "a.Content" works for HREFs but not for tables.

    Can anyone explain?

    Thanks
     
    just_a_w, Jan 3, 2006 IP
  2. FeelLikeANut

    FeelLikeANut Peon

    Messages:
    330
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This will select all A elements with the attribute CLASS set to "Content". For example,
    <a href="Blah" class="Content">Blah</a>
    Code (markup):
    This will select any A element that is a decendant of any other element with the attribute CLASS set to "Content". For instance,
    <p class="Content">
      <a href="Fee">Fee</a>
    </p>
    
    <div class="Content">
      <p>
        <span><a href="Fi">Fi</a></span>
      </p>
    </div>
    
    <table>
      <tr>
        <td class="Content"><a href="Fo">Fo</a></td>
      </tr>
    </table>
    
    [color=red]This next example will not be selected; the A element is not a decendant of itself[/color]
    <p><a href="Fum" class="Content">Fum</a></p>
    Code (markup):
     
    FeelLikeANut, Jan 3, 2006 IP
    Colleen and nevetS like this.
  3. eKstreme

    eKstreme Guest

    Messages:
    131
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, they are two different types of CSS selectors.

    The first one (a.Content) specifies all anchor tags that have a class of "Content".

    The second one (.Content A), selects all anchor tags found within any other tag of class "Content". It will work if you have P, DIV, or any other elements, as long as their class is "Content".

    Hope this helps.
     
    eKstreme, Jan 3, 2006 IP