Html 在另一个 <section> 标签内有一个 <section> 标签是否有效?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9916354/
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:23:56  来源:igfitidea点击:

Is it valid to have a <section> tag inside another <section> tag?

html

提问by timofey.com

Are <section>tags allowed to be included within another <section>tag? Will it validate in HTML5?

是否<section>允许标签包含在另一个<section>标签中?它会在 HTML5 中验证吗?

回答by o.v.

Yes! w3 encourages you to explicitly wrap sections in elements of sectioning content, instead of relying on the implicit sections generated by having multiple headings in one element of sectioning contentand nested <section>'s are allowed.

是的!w3 鼓励您将节显式地包装在分节内容的元素中,而不是依赖于通过在分内容的一个元素中具有多个标题而生成的隐式节,并且允许嵌套的 <section>。

回答by SirCommy

Yes, since a website is generally divided into one or more sections, use it as long as you feel it describes the structure. A layout can have 1 or even tens of SECTION elements, just know that it is NOT a DIV replacement :) DIVs are still used and recommended (usually for grouping means).

是的,因为一个网站通常被分成一个或多个部分,只要你觉得它描述了结构就可以使用它。一个布局可以有 1 个甚至几十个 SECTION 元素,只要知道它不是 DIV 替代品:) DIV 仍然被使用和推荐(通常用于分组手段)。

回答by theJollySin

Yes, that will work fine. At least, it works for me.

是的,那会很好用。至少,它对我有用。

You can try it out here.

你可以在这里试试。