简体   繁体   English

HTML 5 Section和Main语义标签的使用

[英]HTML 5 Section and Main semantic tags use

While studying the HTML 5 semantic tags, I've ran upon some doubts on how to proper utilize the main and section tags, and since the W3Schools reference seems a little vague and other references on the Web seems to diverge I would like to know if there is a proper guideline to the following questions or if its pretty much up to the programmer: 在研究HTML 5语义标记时,我对如何正确利用mainsection标记存有疑问,并且由于W3Schools参考似乎有点含糊,而Web上的其他参考似乎有所不同,我想知道是否有以下问题的适当指南,或者是否完全由程序员决定:

  1. Does the main tag also has the meaning of grouping related elements or in that case should it be within a section tag? 标签是否也具有对相关元素进行分组的含义,或者在这种情况下,它是否应位于区段标签中?
  2. Does it make sense to wrap single elements, such as an image, into a section tag? 将单个元素(例如图像)包装到section标签中是否有意义?
  3. It's pretty common to have a header and footer of the page (not inside any section), in that case, should the remaining in between those tags be wrapped inside a section tag, as if delimiting the "content" of the page? 在页面的页眉页脚 (不在任何节内)是很常见的,在这种情况下,应该将这些标签之间的其余部分包装在section标签内,就像在界定页面的“内容”一样吗?

Does the main tag also has the meaning of grouping related elements 主标签是否也具有对相关元素进行分组的含义

Only to the same extent that <div> groups related elements. 仅在与<div>分组相关元素相同的程度上。 The primary purpose of <main> is to indicate where the dominant content of the page starts. <main>的主要目的是指示页面主要内容的起始位置。 (and additionally, according to the WHATWG spec but not the W3C one, where the dominant content of the page resumes ). (此外,根据WHATWG规范,但不是W3C规范,页面的主要内容将在那里恢复 )。

or in that case should it be within a section tag? 还是在那种情况下应该在section标签中?

A section tag is one way of grouping your content, to indicate that its contents are on a particular theme, in a way that differs from the content which is not in the section. 区段标签是对内容进行分组的一种方法,用于指示其内容在特定主题上,其方式不同于不在该区段中的内容。 Typically, you can and should give the section a heading using a <h[1-6]> element, which states what that theme is. 通常,您可以并且应该使用<h[1-6]>元素为该部分指定标题,以说明该主题是什么。

Does it make sense to wrap single elements, such as an image, into a section tag? 将单个元素(例如图像)包装到section标签中是否有意义?

Rarely. 很少。 For one thing that would mean that the section didn't contain a heading. 一件事意味着该节不包含标题。 See above. 往上看。 It's unlikely that any new information would be conveyed by wrapping an image on its own in a section tag. 通过将图像自身包装在section标签中,不太可能传达任何新信息。

It's pretty common to have a header and footer of the page (not inside any section), in that case, should the remaining in between those tags be wrapped inside a section tag, as if delimiting the "content" of the page? 在页面的页眉和页脚(不在任何节内)是很常见的,在这种情况下,应该将这些标签之间的其余部分包装在section标签内,就像在界定页面的“内容”一样吗?

No. The "content" of the section is the section less its header and footer. 否。该部分的“内容”是该部分减去其页眉和页脚。 There's no need to add another sectioning element container. 无需添加其他切片元素容器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM