span5标记在HTML5中包含哪些元素? [英] What elements can a span tag contain in HTML5?
问题描述
< span>
内有一个div出现了几个错误,这是不允许的。我尝试将范围内的所有< div>
更改为< p>
,但收到几乎相同的错误。 http://www.w3schools.com/html5/tag_span.asp 没有明确说出< span>
中允许有哪些元素,并且验证程序的错误也不允许:
第85行,第69列:元素p不允许作为元素的子元素跨越
此上下文。 (抑制这个子树的进一步错误。)
2个问题:
1)在< span>
?
<2>中允许使用哪些元素2)在另一个中允许哪些元素?我已使用Google搜索,但没有看到任何有W3C标记的内容。 只有行内元素可以包含在行内元素中。
span
是一个内联元素。因此,像 a
, img
, sup
等标签。可以在一个范围内,但块级元素,如 div
和 p
不能。 更新 p $ p
$ b
实际上,默认使用内嵌显示的不同元素行为会有所不同。一些inline元素可能允许块元素(例如 a
),而另一些元素则不会(例如 span
) 。
如果您对HTML标签可能包含的内容感兴趣,您最正式的源代码是HTML元素上的WHATWG页面。您可以检查任何HTML元素,并查看允许哪些内容(请参阅每个元素的内容模型):
http://www.whatwg.org/specs/web-apps/current-work/multipage/ #auto-toc-4
下面是span标签的定义,它表示只允许使用'phrasing'内容。
So I have been a CLI or Cron developer in PHP for most my career and now I am learning why I did not like UI work in school ;) I am dealing with HTML5 validation here and I am not finding an answer to a question that is for curosity. I ran the W3C HTML5 validation on my home page and I got several errors around a div being within a <span>
and that is not allowed. I tried changing all <div>
within spans to a <p>
but recieve pretty much the same error. http://www.w3schools.com/html5/tag_span.asp does not explicitly say what elements are allowed within a <span>
and neither does the error from the validator:
Line 85, Column 69: Element p not allowed as child of element span in this context. (Suppressing further errors from this subtree.)
2 questions:
1) What elements if any are allowed within a <span>
?
2) Where can I reference for what elements are allowed within another? I have googled but see nothing that has a "W3C" stamp on it.
Only inline elements may be contained within inline elements. span
is an inline element. So, tags like a
, img
, sup
, etc. can go within a span, but block level elements like div
and p
cannot.
UPDATE
In reality, different elements which default to inline display behave differently. Some "inline" elements may allow block elements (a
for example), while others don't (like span
).
If you're interested in what an HTML tag may contain, your most official source is the WHATWG page on HTML elements. You can check any HTML element and see what content is permitted (see 'Content Model' for each element):
http://www.whatwg.org/specs/web-apps/current-work/multipage/#auto-toc-4
Here's the definition of the span tag, which indicates that only 'phrasing' content is allowed.
这篇关于span5标记在HTML5中包含哪些元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!