Html 可以嵌套在 P 元素中的 HTML5 元素列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9852312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 23:19:49  来源:igfitidea点击:

List of HTML5 elements that can be nested inside P element?

htmlnested

提问by Lone Learner

I am trying to figure all the valid HTML5 elements that can be nested inside paragraph elements such that w3 validator doesn't show any errors. I mean I am trying to figure all tags that can replace the dots in the following code such that w3 validator doesn't show any errors:

我试图找出所有可以嵌套在段落元素中的有效 HTML5 元素,以便 w3 验证器不会显示任何错误。我的意思是我试图找出所有可以替换以下代码中的点的标签,以便 w3 验证器不会显示任何错误:

<p>...</p>

Is there such a list available? I tried searching on Google without any luck.

有这样的清单吗?我尝试在谷歌上搜索但没有任何运气。

Even if the converse list is available, i.e. elements that can not be nested inside paragraph elements, it is good enough for me.

即使逆列表可用,即不能嵌套在段落元素内的元素,对我来说也足够了。

回答by Matt Ball

The HTML5 spectells us that the <p>element's content model is phrasing content. Phrasing content is defined by the spec:

HTML5 规范告诉我们<p>元素的内容模型是phrasing content。短语内容由规范定义:

3.2.5.1.5 Phrasing content

Phrasing content is the text of the document, as well as elements that mark up that text at the intra-paragraph level. Runs of phrasing content form paragraphs.

  • a(if it contains only phrasing content)
  • abbr
  • area(if it is a descendant of a mapelement)
  • audio
  • b
  • bdi
  • bdo
  • br
  • button
  • canvas
  • cite
  • code
  • command
  • datalist
  • del(if it contains only phrasing content)
  • dfn
  • em
  • embed
  • i
  • iframe
  • img
  • input
  • ins(if it contains only phrasing content)
  • kbd
  • keygen
  • label
  • map(if it contains only phrasing content)
  • mark
  • math
  • meter
  • noscript
  • object
  • output
  • progress
  • q
  • ruby
  • s
  • samp
  • script
  • select
  • small
  • span
  • strong
  • sub
  • sup
  • svg
  • textarea
  • time
  • u
  • var
  • video
  • wbr
  • text
  • 3.2.5.1.5 短语内容

    短语内容是文档的文本,以及在段落内标记该文本的元素。大量的措辞内容形成段落。

  • a(如果它只包含短语内容)
  • abbr
  • area(如果它是map元素的后代)
  • audio
  • b
  • bdi
  • bdo
  • br
  • button
  • canvas
  • cite
  • code
  • command
  • datalist
  • del(如果它只包含短语内容)
  • dfn
  • em
  • embed
  • i
  • iframe
  • img
  • input
  • ins(如果它只包含短语内容)
  • kbd
  • keygen
  • label
  • map(如果它只包含短语内容)
  • mark
  • math
  • meter
  • noscript
  • object
  • output
  • progress
  • q
  • ruby
  • s
  • samp
  • script
  • select
  • small
  • span
  • strong
  • sub
  • sup
  • svg
  • textarea
  • time
  • u
  • var
  • video
  • wbr
  • 文本