p#div vs #div p

Discussion in 'CSS' started by CSS_Question, Dec 17, 2008.

  1. #1
    Good Day:

    Appreciate if someone may reply the different of the below, specifically on the # (hatch symbol) in CSS coding:

    p#div

    #div p


    Many thanks in advance for your response.
     
    CSS_Question, Dec 17, 2008 IP
  2. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #2
    The first means an element has an 'id' of div and is a child of <p>.
    The second means there is an element with an 'id' of 'div' with a <p> child.

    iow, the first might look like this:
    <p>Hello<span id="div">There!</span></p>

    And the second might be:
    <li id="div"><p>Hello There!</p></div>

    But I'd bet that's not what you were expecting.
     
    drhowarddrfine, Dec 17, 2008 IP
  3. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #3
    Oops, Doc. There's no space in the first example. p#div refers to a p named 'div': <p id="div">Hello, world.</p>. And, it's still not what he was expecting. :)

    cheers,

    gary
     
    kk5st, Dec 17, 2008 IP
  4. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #4
    You're right, Gary. You got my back. :)
     
    drhowarddrfine, Dec 17, 2008 IP
  5. CSS_Question

    CSS_Question Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Good Day Gurus:

    Many thanks for the very prompt reply, it is truly appreciated.

    Thanks for making the explanation so simple yet informative. Yes, the question is as simple as you think, no trick!

    BRAVO!
     
    CSS_Question, Dec 17, 2008 IP