tag is a block-level element in XHTML?

2019-02-25 03:08发布

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?

标签: html xhtml
2条回答
闹够了就滚
2楼-- · 2019-02-25 03:46

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.

查看更多
趁早两清
3楼-- · 2019-02-25 03:47

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.

查看更多
登录 后发表回答