多个
和<页脚>在 HTML5 文档中

发布于 2024-12-21 05:39:59 字数 1150 浏览 3 评论 0原文

在 HTML 5 中使用多个

是否可以,如果可以,那么在语义上不会不正确,并且不会让移动阅读器感到困惑吗?

我看到很多网站使用类似

<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>

Is it fine to use multiple <header> and in HTML 5, if yes then isn't semantically incorrect and won't it confuse mobile readers?

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 © year</p>
    </footer><!-- .f1 -->

</body>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无戏配角 2024-12-28 05:39:59

是的,多个

元素就可以了。它们的使用方式与大多数人使用的

来自马嘴:

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

页脚元素代表其最近祖先的页脚
分段内容或分段根元素。页脚通常
包含有关其部分的信息,例如作者、链接
相关文档、版权数据等。

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

请注意,正如我所说,这些并不用于像人们使用

那样创建部分,它在规范中提到了这种混乱:

页脚元素不是分段内容;它没有介绍
新部分。

因此,再次从“技术上”来说,最后一个页脚引入了一个新部分,并且不是语义性的。无论如何,从规范的角度来看。

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.

From the horses mouth:

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.

And

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.

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

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:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文