Results 1 to 2 of 2

Thread: Precise Meaning of the <p> tag

  1. #1
    Join Date
    Mar 2011
    Posts
    2,171
    Thanks
    61
    Thanked 121 Times in 117 Posts
    Blog Entries
    4

    Exclamation Precise Meaning of the <p> tag

    Removed
    Last edited by keyboard; 07-05-2012 at 10:59 PM. Reason: Removed post

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,475
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The p tag (which stands for paragraph) opens a block level element similar to a div tag. There are two major differences:

    1. It cannot contain another block level element. This means that if there's a div, blockquote, table, etc., or even just another p inside it, it closes automatically at the beginning of that other block level element. This is regardless of where you might place the </p> tag. It is the only block level element that behaves this way.

    2. Unlike div which by default in all browsers has no margin, many if not all browsers give the p element default top and bottom margins. And these vary by browser.


    See also:

    http://www.dynamicdrive.com/forums/s...ad.php?t=40199

    and:

    http://www.w3.org/TR/html401/struct/text.html#edef-P

    This standard seems to be being softened in HTML 5, perhaps allowing nested block level elements other than lists, but the wording is vague:

    http://www.w3.org/TR/html5/content-m...html#paragraph

    Individual browsers might vary. But I suspect most if not all still adhere to the "cannot contain block-level elements (including P itself)" rule.
    Last edited by jscheuer1; 07-05-2012 at 01:56 PM. Reason: see also, etc.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Tags for this Thread

Bookmarks

Posting Permissions

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