html - <span> 标签中可以包含任何类型的标签吗?

标签 html xhtml

<div>之类的标签, <form> , <pre>等..允许在<span>内?

最佳答案

span 元素是一个内联 元素,它应该只包含其他内联 元素,不包含 block 元素.

来自 the spec :

Generally, block-level elements may contain inline elements and other block-level elements. Generally, inline elements may contain only data and other inline elements. Inherent in this structural distinction is the idea that block elements create "larger" structures than inline elements.

通用 block 级分组元素是 div。通用内联级分组元素是 span

同样,来自 the spec :

The DIV and SPAN elements, in conjunction with the id and class attributes, offer a generic mechanism for adding structure to documents. These elements define content to be inline (SPAN) or block-level (DIV) but impose no other presentational idioms on the content.

关于html - <span> 标签中可以包含任何类型的标签吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5545884/

相关文章:

html - 关键帧图像幻灯片有效但不适用于 WordPress

xhtml - 浏览器将如何区分 XHTML 1.0 和 XHTML 5?

html - 如何保证自定义滚动条?

javascript - 难以理解 if 语句代码

java - 获取文件过早结束异常

xhtml - "On Page SEO"是什么意思?

javascript - HTML 中多个表中同一列的相同 [不固定] 宽度

html - 在不指定宽度的情况下 float div

html - 表格 Thead 与 TD Cells 不匹配并且不符合表格大小

javascript - 如何使 Highcharts 中呈现的标签始终可见并且仍然相对于单击或悬停的点