Log in

View Full Version : Resolved Precise Meaning of the <p> tag



keyboard
07-05-2012, 06:34 AM
Removed

jscheuer1
07-05-2012, 12:54 PM
The p tag (which stands for paragraph) opens a block level element similar to a div tag. There are two major differences:


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.


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/showthread.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-models.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.