我知道在 HTML4.0 中
<p>
标签不是 block 级元素。 在 XHTML 1.0 中呢?
谢谢
这是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).
那是我的误解吗?
最佳答案
据我所知,p
是一个至少可以追溯到 HTML 3.2 的 block 级元素。
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
而且 XHTML 1.0 实际上与 HTML 4.01 完全相同,只是不那么宽松。这意味着元素服务于相同的目的,是相同的“级别”( block 、内联、表格),只适用这些规则:
- 所有元素和属性名称必须以小写形式出现
- 所有属性值都必须用引号引起来
- 非空元素需要结束标签
- 空元素使用空格和尾部斜线终止
- 不允许属性最小化
- 在严格的 XHTML 中,所有内联元素都必须包含在 block 元素中
编辑:
The P element represents a paragraph. It cannot contain block-level elements (including P itself).
这只是意味着 p
不能拥有内部的其他 block 级元素,这意味着因为它是 block 级的,所以它不能包含自己。
关于html - <p> 标签是 XHTML 中的 block 级元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3428828/