html - <p> 标签是 XHTML 中的 block 级元素?

标签 html xhtml

我知道在 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/

相关文章:

html - 在表格中将文本右对齐

html - 对于 <a> anchor 标记, 'name' 属性是否已过时?

java - 如何使用递增计数器在 XSLT 中提供唯一 ID?

html - 如何仅在父 div 上保持行高?

php - 如何使 PDF 文件可在 HTML 链接中下载?

html - 减少 HTML <UL> 和 <LI> 元素之间的差距

html - 您知道 Net 上学习 XHTML 1.0 strict 的最佳网站吗?与 W3schools.com 一样,但内容更好、最新?

javascript - 如何将列表中的文本从一行换成另一行

html - 为什么这个简单的 SVG 图标会缩放?

html - 为什么 Chrome、Firefox 和 IE 都以不同方式呈现固定宽度的 SELECT 控件?