h1是否需要成为标头标记中的第一个语义元素? [英] Does the h1 need to be the first semantic element in a header tag?

查看:72
本文介绍了h1是否需要成为标头标记中的第一个语义元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Chrome大纲扩展程序检查我页面的语义.在文档主标题标签中的h1之前具有任何结构元素似乎是一个问题.我当时以为顺序无关紧要,但显然确实如此:

I am using a Chrome outliner extension to check the semantics of my page. It seems to be a problem to have any structural element before the h1 in the document main header tag. I was thinking the order does not matter, but apparently it does:

+Document Body
  +Header
    +nav
      +h1 Main Navigation
    +h1 MyPage
  -Section
  -Footer

像这样概述:

Untitled Body
  Main Navigation
  MyPage
  etc...

但是当h1是标题中的第一个元素时:

But when the h1 is the first element in my header:

+Document Body
  +Header
    +h1 MyPage
    +nav
      +h1 Main Navigation
  -Section
  -Footer

它确实像这样概述:

MyPage
  Main Navigation
  etc...

那是为什么?大纲工具是否有问题,或者我是否理解HTML5语义中的某些错误? W3C规范似乎没有提及它: http://dev .w3.org/html5/spec/Overview.html#the-header-element

Why is that? Is the outliner buggy, or did I understand something wrong in HTML5 semantics? The W3C Specification does not seem to mention it: http://dev.w3.org/html5/spec/Overview.html#the-header-element

推荐答案

在重新查看规格后,我同意h1不必是第一个元素.我怀疑问题与您使用的chrome扩展有关.

After revisiting the specs, I agree that the h1 does not have to be the first element. I suspect the issue is with the chrome extension you are using.

我通过此HTML概述工具运行了以下两种情况,并收到了相同的结果(我的导航"出现在我的标题"下):

I ran the following two scenarios through this HTML outlining tool and received the same results (My Navigation appears under My Header):

标题下有h1第二个元素:

With h1 second element under header:

<body>
<header>
<h1>My Header</h1>
<nav><h1>My Navigation</h1></nav>
</header>
<section><h1>My Section</h1></section>
<footer></footer>
</body>

在标题下有H1第一个元素:

With H1 first element under header:

<body>
<header>
<nav><h1>My Navigation</h1></nav>
<h1>My Header</h1>
</header>
<section><h1>My Section</h1></section>
<footer></footer>
</body>

这篇关于h1是否需要成为标头标记中的第一个语义元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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