HTML 头标签的顺序错误
在此布局中,它无效,因为 H1 不是第一个呈现的头元素...这是一个可怕的罪恶还是可以?有办法解决这个问题吗?两列的长度都是可变的,所以我看不到任何解决办法。
引用
有人要求我引用此内容:
http://www.w3.org/WAI/ER/IG/ert/ert-19991221.html#Technique3.5.A
应检查标头元素(H1-H6)以确保它们按照以下规则嵌套 文档中的第一个标题元素必须是 H1 文档中只能有一个 H1 元素 标题级别的增加不得超过 1 级。示例:H1 后面的 H2 很好。 H1 之后的 H3 很糟糕。 标题元素可以减少任何级别。示例:H5 后面的 H2 就可以。
In this layout it's not valid because H1 isn't the first rendered head element... is this a terrible sin or is it ok? Any way to fix this? Both columns are variable length so I don't see any way round this.
Citation
Someone asked me to citate this:
http://www.w3.org/WAI/ER/IG/ert/ert-19991221.html#Technique3.5.A
Header elements (H1-H6) should be checked to ensure they are nested according to the following rules
The first header element in the document must be H1
There must be only one H1 element in the document
Header levels must not increase by more than 1 level. Example: H2 following H1 is good. H3 following H1 is bad.
Header elements can decrease by any level. Example: H2 following H5 is OK.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不同标签在哪里呈现并不重要,重要的是语义。
H1
只是表示标题级别高于H2
、H3
等。Where the different tags are rendered is not important, it's all about semantics.
H1
simply means that the heading is higher level thanH2
,H3
, etc.应该可以解释为某些
的副标题。
在 HTML5 中,您可以通过嵌套
标签来定义文档层次结构,并完全忽略
-
标签。您可以在此处查看 HTML5 文档大纲,其中说明了此属性。
当然,最简单的解决方法是将列按其他顺序浮动。目前它们都向左浮动。切换标记中的顺序,向右浮动,突然间,标题的顺序就正确了!
顺便说一句,您的网站的“本周焦点”部分的语义是错误的。它应该更像 这个
The
<h2>
s should be interpretable as subheadings of some<h1>
.In HTML5, you can define the document hierarchy by nesting
<section>
tags, and completely ignoring the<h1>
-<h6>
tags. You can see an HTML5 document outliner here, which illustrates this property.Of course, the simplest fix is to just float your columns in the other order. At present they are both floated left. Switch the order in the markup, float 'em right, and suddenly, the headings are in the right order!
On a side note, the semantics of the 'This Weeks Spotlight' section of your site is wrong. It should be more like this
我不知道 H1 不是页面上的第一件事有什么大不了的。我知道谷歌会查看标题来尝试建立上下文。例如,他们说应该只有一个 H1 标签,并且应该是一个很好的短标题来描述页面的内容。一般来说,h1 下方的文本(或副标题)应该随之而来,越来越详细地描述您的内容的内容。无论如何,这就是理论。
无论如何,像这样的事情怎么样?
I don't know how big of a deal it is that H1 isn't the first thing on the page. I know Google will look at headings to try to establish context. They say that there should only be one H1 tag, for example, and that it should be a good short heading that describes the content of the page. In general, the text (or subheadings) underneath the h1 should then follow suit describing what your content is about in greater and greater detail. That's the theory anyway.
In any case, what about something like this?