我可以把 <section> 放在 <header> 里面吗?
Can I put a <section> inside a <header>?
我没能找到描述 HTML5 标签 header
和 section
(或 footer
和 section
)之间关系的参考资料.大多数示例将 p
元素放在 header 和页脚中。
将 section
元素放入 header 中是否合法且可取?
参考文献:
- The main element - 您不能将
main
元素放入 article
- "Nesting <article> in <section> or Vice Versa?" in HTML5 semantic elements - 将
article
放入 section
是有效的,反之亦然(尽管语义不同)
是的,你可以。
形式上,content model of header elements 是
Flow content, but with no header or footer element descendants.
而 contexts in which section elements can be used 是
Where sectioning content is expected.
Sectioning content is subset of flow content,所以这意味着任何地方都需要流内容,但明确指出不允许的地方除外,正如我们在上面看到的,它不适用于 header。
我没能找到描述 HTML5 标签 header
和 section
(或 footer
和 section
)之间关系的参考资料.大多数示例将 p
元素放在 header 和页脚中。
将 section
元素放入 header 中是否合法且可取?
参考文献:
- The main element - 您不能将
main
元素放入article
- "Nesting <article> in <section> or Vice Versa?" in HTML5 semantic elements - 将
article
放入section
是有效的,反之亦然(尽管语义不同)
是的,你可以。
形式上,content model of header elements 是
Flow content, but with no header or footer element descendants.
而 contexts in which section elements can be used 是
Where sectioning content is expected.
Sectioning content is subset of flow content,所以这意味着任何地方都需要流内容,但明确指出不允许的地方除外,正如我们在上面看到的,它不适用于 header。