首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HTML5 -文章结构:节和标题

HTML5 -文章结构:节和标题
EN

Stack Overflow用户
提问于 2014-08-21 00:21:54
回答 2查看 259关注 0票数 2

我发现了许多关于HTML5最佳实践的相互矛盾的信息,我想知道我的文章结构是否正确。一般而言,此站点上的页面将由带有导航、文章和页脚的页眉组成。

这是我的基本结构:

代码语言:javascript
复制
<body>
    <header>Header content
        <nav>Navigation</nav>
    </header>
    <article>
        <header>
            <h1>Beans, beans</h1> <!--Main title for article-->
            <h2>Good for your heart?</h2> <!--Subtitle for article-->
        </header>
        <section>
            <header>
                <h3>Legume-based Flatulence</h3> <!--Section title-->
            </header>
            <p>Lorem ipsum beans beans beans.</p>
        </section>
        <section>
            <header>
                <h3>Gas and Good Feelings</h3>
            </header>
            <p>Correlation does not imply causation.</p>
            <footer> <!--Section footer for sources or...?-->
                Source: Phenomenological Farts, a Study in Siena
            </footer>
        </section>
        <section>
            <header>
                <h3>Beans for Every Meal?</h3>
            </header>
            <p>This is probably a terrible idea.</p>
        </section>
        <footer> <!--Article footer for additional downloads, etc-->
            <a href="#">Download this article!</a>
        </footer>
    </article>
    <footer>
        Footer content.
    </footer>
</body>

这有意义吗?在文章的章节中使用页眉和页脚可以吗?

EN

回答 2

Stack Overflow用户

发布于 2014-08-21 11:43:36

当你不确定哪些标签允许在其他标签中使用时,只需在w3.org上查看规范。或者通过validator运行您的代码。The spec声明sectionheaderarticle标签可以在任何允许flow elements的容器中使用。因此,到目前为止,您所拥有的是有效的。

票数 2
EN

Stack Overflow用户

发布于 2014-08-21 11:54:57

我本打算推荐使用http://www.webmonkey.com/2013/04/w3c-drops-hgroup-tag-from-html5-spec/对报头进行分组,但现在不再推荐了。也许可以使用header来代替它。来自W3C的更多信息和建议:http://www.w3.org/html/wg/drafts/html/master/common-idioms.html#sub-head

然后,我还会将其他h3更改为h2s,因为它们是节标题。

最后,由hx组成的header soley是一种冗余。

有关HeadersFooters的更多信息

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25409771

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档