多个< header>和< footer>在HTML5文档中 [英] Multiple <header> and <footer> in a HTML5 document

查看:77
本文介绍了多个< header>和< footer>在HTML5文档中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否允许和确定使用多个< header> 并在HTML 5中使用,如果是,那么它在语义上是否不正确,并且会混淆屏幕阅读器用户?

Is it Allow and Ok to use multiple <header> and in HTML 5, if yes then is it not semantically incorrect and will confuse to screen reader users?

我看到许多网站用途,例如

I saw many site uses like

<body class="home">
    <header class="hd1">
        <hgroup>
        <h1>HTML5 Documnet</h1>
        <h2>tagline</h2>
        </hgroup>
    </header><!-- .hd1 -->
    <div class="main">
        <section class="hs1">
            <header>
            <h1>This is a Page Sub Title</h1>
            </header>

            <p>Some content...</p>
            <h2>Demonstrating EM and STRONG</h2>

            <p><strong>This text will have more importance (SEO-wise and contextually)</strong></p>         

            <footer>
            <p>Author: <cite>Louis Lazaris</cite></p>
            </footer>

        </section>
    </div><!-- .main -->
    <footer class="f1">
    <p>copyright &copy; year</p>
    </footer><!-- .f1 -->

</body>


推荐答案

是,多个< header> < footer> 元素都可以。它们与< div id = header> 的用法不同,因为大多数人使用它们。从技术上讲,页眉和页脚代表节的页眉和页脚。一部分是页面的一部分,例如一篇文章,其中包含标题标签(如< h1> ),然后是内容,然后是页脚内容,例如版权,引文,参考文献等。

Yes, multiple <header> and <footer> elements are fine. They aren't used the same as <div id="header"> as most people use them for. Technically speaking, header and footer represent a header and footer of a section. A section being a piece of the page such as an article that contains header tags like <h1> and then content, then footer stuff like copyrights, citations, references, etc.

从马口开始:


标头元素通常旨在包含该节的标题
(h1-h6元素或hgroup元素),但这不是必需的。
标头元素还可以用于包装部分的目录,
a搜索表单或任何相关徽标。

A header element is intended to usually contain the section's heading (an h1–h6 element or an hgroup element), but this is not required. The header element can also be used to wrap a section's table of contents, a search form, or any relevant logos.


footer元素表示其最接近祖先
的sectioning内容或sectioning根元素的页脚。页脚通常
包含有关其部分的信息,例如谁写的,与
相关文档的链接,版权数据等。

The footer element represents a footer for its nearest ancestor sectioning content or sectioning root element. A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.

直接来自规范,网址为: http://dev.w3.org/html5/spec /Overview.html

Directly from the spec at: http://dev.w3.org/html5/spec/Overview.html

请注意,就像我说的那样,这些内容并不像创建< div id = header / footer> 它在规范中提到了这种混淆:

Note that as I said these are not used to create sections like people did with <div id="header/footer"> it mentions this confusion in the spec:


footer元素未分段内容;它不会引入新的
部分。

The footer element is not sectioning content; it doesn't introduce a new section.

因此,从技术上讲,最后一个 在那里的页脚引入了一个新的部分,它不是语义的。无论如何,从规范的角度来看。

So, again, "technically" speaking, that last footer you have there introduces a new section and isn't semantic. From the spec's point of view anyways.

这篇关于多个&lt; header&gt;和&lt; footer&gt;在HTML5文档中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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