在HTML5中,最好使用< section>和< h1>而不是< h2> - < h6>? [英] In HTML5, is it better to use <section> and <h1> instead of <h2>–<h6>?

查看:177
本文介绍了在HTML5中,最好使用< section>和< h1>而不是< h2> - < h6>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在研究HTML5的新版标签时,我想知道h1,h2,h3,h4,h5和h6标签的处理......

In studying up on HTML5's new section tag, I'm wondering about the handling of h1, h2, h3, h4, h5, and h6 tags...

HTML5规范说[h1,h2等]元素代表其各个部分的标题 http://www.w3.org/TR/html5/sections.html#the-h1-h2 -H3-H4-H5-和-H6元素的)。此外,在规范的4.4.11标题和部分部分中,目前有三个构建关于苹果的文档的示例。

The HTML5 specification says that "[h1, h2, etc.] elements represent headings for their sections" (http://www.w3.org/TR/html5/sections.html#the-h1-h2-h3-h4-h5-and-h6-elements). Further in the spec's "4.4.11 Headings and sections" section, there are currently three examples of structuring a document about apples.

如果我们遵循第一个规范,即规定标题元素应该代表其部分的标题,那么第三个苹果示例似乎是最多正确的结构(即,在每个部分和子部分中使用标题的h1标签)。使用这个逻辑似乎很少使用h2,h3,h4,h5和h6标签,如果有的话。

If we follow the first specification, which states that heading elements "should represent headings for their sections," it seems the third apple example is the most correct structure (i.e., using h1 tags for the heading in each section and subsection). Using this logic it seems that the h2, h3, h4, h5, and h6 tags would be used rarely, if at all.

这就是我想知道的:应该使用h2,h3,h4,h5或h6标签,实际上它们基本上是标记小节吗?使用section标签来分隔各个部分是不是更有意义,每个部分都有自己的标题,而不是依赖于h2,h3等来启动隐式部分? (标题和部分部分还讨论了使用h2,h3等隐含的部分。)

This is what I'm wondering: should h2, h3, h4, h5, or h6 tags really be used if, in reality, they are basically marking up subsections? Does it not make more sense to use section tags to separate sections, each with their own header, rather than relying on h2, h3, etc. to start implicit sections? (The "Headers and sections" section also talks about the sections implied by using h2, h3, etc.)

也许这是我的关系数据库知识导致偏见,但创建带有数字的多个标题标记(h 1 ,h 2 ,h 3 )似乎是不好的做法,从技术上讲,它们各自都是自己的标题或者小节。

Perhaps it's my relational database knowledge causing a bias, but creating multiple header tags with numbers (h 1, h 2, h 3) seems like bad practice, when technically they are each heading their own section or subsection.

你有什么看法?

推荐答案

似乎该规范甚至声明h1优先于所有其他:

It seems that the spec even states that h1 has preference over all the others:


章节可能包含任何等级的标题,但强烈建议作者要么只使用h1元素,要么使用适当等级的元素作为该部分的嵌套级别。

Sections may contain headings of any rank, but authors are strongly encouraged to either use only h1 elements, or to use elements of the appropriate rank for the section's nesting level.

然而令我不安的是:


还鼓励作者明确地将部分包含在切片内容的元素中,而不是依赖于在分区内容的一个元素中包含多个标题而生成的隐式部分。

Authors are also encouraged 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 content.

现在我们得到的部分,文章很精彩,导航和旁边用来防止div-itis。但是如果我们需要为每个部分明确地使用section元素而不是我们最终有更多的section元素,那么我们就有了div。我觉得有一个很好的例子,它会出现。

Now it is wonderful that we got section, article, nav and aside to use to prevent div-itis. But if we need to explicitly use a section element for each section than we end up with more section elements then we ever had divs. I feel a strong case of section-itis coming on.

这篇关于在HTML5中,最好使用< section>和< h1>而不是< h2> - < h6>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆