将文档<header>放在文档中间</header>是无效/令人困惑的

时间:2012-07-05 14:38:34

标签: html html5 accessibility semantic-markup

我目前有这样的设置:

<section id="intro"></section>
<header></header>
<section></section>
<section></section>
<footer></footer>

header元素是一个带有站点名称和基本信息的粘性标题。直到用户滚过#intro之后它才显示,因此它在DOM中。我想知道,从语义和可访问性的角度来看,将它变成div或section更有意义。

1 个答案:

答案 0 :(得分:5)

<header>代码为not required to be at a specific position in your document,但不应包含其他<header><footer><address>代码的子代。另一方面,<div>元素是strongly suggested as a last-resort element only,当另一个元素在语义上更适合时,要避免使用<header>元素。看来你对{{1}}的使用与它的推荐用法非常吻合,但是你应该记住,IE8和早期版本不支持它,并且这些浏览器实际上不合适。