Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] what's difference between these selectors ?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #153678
    amis
    Participant

    Hey

    I am using the following

    #selector or .selector

    but when i download and template or other works i find them using these

    tagName #parent .selector what’s diff between two method ?

    isn’t my method 100% true ?

    #153683
    Paulie_D
    Member

    #selector or .selector will usually be enough.

    There should never be a need for tagName#selector (eg. div#header) because the # is an ID and should be unique on the page.

    You might occasionally see div.selector but this usually only where the class is quite general and could be applied to multiple element types.

    So div.selector would apply only to divs with that class but .selector would apply to ANY element with that class whether is was a div or not.

    #153706
    amis
    Participant

    thx very much for ur sharing ,
    ans what’s diff between theses also

    .selector.selector and .selector .selector

    #153708
    Paulie_D
    Member

    .class1.class2 selects an element that has both classes.

    .class1 .class2 selects an element with a class of .class2 that is a child of an element that has a class of .class1.

    http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.