Paragraph inside paragraph

Discussion in 'HTML & Website Design' started by boba5555, Nov 22, 2009.

  1. #1
    Hello,

    I tried HTML example

    <p> text1 <b> text2 <p> text3 </b>

    and got text2 and text3 bolded. Opera in its DOM structure shows

    <p> text1 <b> text2 <p> text3 </p> </b> </p>

    but is that possible to have paragraph inside paragraph? I thought its actually against the HTML rules and convention. How in this case someone should act according to specification? Could you point me a page where I can read it? I am not sure what are the actual rules when it is about "block inside block" situations. If <p> can't be inside another <p>, how then this example should be handled? Thank you in advance.

    Best regards,
     
    boba5555, Nov 22, 2009 IP
  2. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #2
    While Opera may find a place for it in the DOM, how it gets rendered is a different animal and may not be consistent between browsers. You can fit a round peg in a square hole, too, but not sure if you'll like the affect on the peg.
     
    drhowarddrfine, Nov 22, 2009 IP
  3. vinpkl

    vinpkl Active Member

    Messages:
    899
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #3
    you can use <span></span> inside <p></p>

    vineet
     
    vinpkl, Nov 22, 2009 IP
  4. boba5555

    boba5555 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks, but is there some page with specification about that? I would like to know what are the exact rules given by specification. Thanks a lot.
     
    boba5555, Nov 22, 2009 IP
  5. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #5
    You are looking for the specification for how a browser handles invalid markup in the DOM? The better thing to do is write valid markup and not worry about the rest.
     
    drhowarddrfine, Nov 22, 2009 IP
  6. boba5555

    boba5555 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    No, I don't care how browser handle something, it was just an example :) I am interested in specification. I know how I should use paragraph, but I would like to see what specification says. For example, http://www.w3.org/TR/html401/struct/text.html#h-9.3.1 says that p can not contain another p - "It cannot contain block-level elements (including P itself)." And, I am interested in general "contains something" rules. So, I do <b>not</b> care what browsers do, that was just an example :)
     
    boba5555, Nov 22, 2009 IP
  7. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #7
    The link you gave is the spec so I don't know what else you want. You can look at the W3C site for the DOM level 0 and level 1 specs, too.
     
    drhowarddrfine, Nov 22, 2009 IP
  8. boba5555

    boba5555 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Ok, thanks :) I just thought there is some kind of summary where are given such rules for which I have asked, but I will carefully read the whole (at at least some parts :)) spec in order to find what I need.
     
    boba5555, Nov 22, 2009 IP