3

I know that in HTML4.0

<p>

tag is not a block-level element. What about in XHTML 1.0?

Thank you

This is the reference for HTML4.0 http://www.w3.org/TR/html401/struct/text.html

The P element represents a paragraph. It cannot contain block-level elements (including P itself).

Was that my misinterpretation?

2
  • it should be noted that with css you can make something that is not a block into something that is and vice versa. Commented Aug 7, 2010 at 1:46
  • may i ask for more info on that, pleas? Thank you. I know that you cannot have an inline containing another element, which will not passed the validation.
    – CppLearner
    Commented Aug 7, 2010 at 1:48

2 Answers 2

6

As far as I know, p is a block-level element going back to at least HTML 3.2.

Most elements that can appear in the document body fall into one of two groups: block level elements which cause paragraph breaks, and text level elements which don't. Common block level elements include H1 to H6 (headers), P (paragraphs) LI (list items), and HR (horizontal rules). Common text level elements include EM, I, B and FONT (character emphasis), A (hypertext links), IMG and APPLET (embedded objects) and BR (line breaks). Note that block elements generally act as containers for text level and other block level elements (excluding headings and address elements), while text level elements can only contain other text level elements. The exact model depends on the element.

http://www.w3.org/TR/REC-html32

And XHTML 1.0 is really the same exact thing as HTML 4.01 except less lenient. Meaning the elements serve the same purpose, are the same "level" ( block, inline, table ), just these rules apply:

  • all elements and attribute names must appear in lower case
  • all attribute values must be quoted
  • non-Empty Elements require a closing tag
  • empty elements are terminated using a space and a trailing slash
  • no attribute minimization is allowed
  • in strict XHTML, all inline elements must be contained in a block element

EDIT:

The P element represents a paragraph. It cannot contain block-level elements (including P itself).

This just means that the p cannot own other block level elements inside, meaning because it is block-level it cannot contain itself.

2
  • so is the p tag a special block-level element, since a block-level element is often the one that can contains itself, and other elements (both block-level and inline)?
    – CppLearner
    Commented Aug 7, 2010 at 1:55
  • Every element is unique, there are certain rules for certain elements, but yes you can consider it "special" since every element is special in its own way. Commented Aug 7, 2010 at 2:00
2

The P element represents a paragraph. It cannot contain block-level elements (including P itself).

This means that the P element is a block level element, and that it cannot contain other block level elements (such as DIV). Since P is itself a block level element, you cannot put a P inside another P.

1
  • 1
    so is the p tag a special block-level element, since a block-level element is often the one that can contains itself, and other elements (both block-level and inline)? thank you.
    – CppLearner
    Commented Aug 7, 2010 at 1:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.