🎶 Sym - 一款用 Java 实现的现代化社区(论坛/BBS/社交网络/博客)平台

📕 思源笔记 - 一款桌面端笔记应用,支持 Windows、Mac 和 Linux

🎸 Solo - B3log 分布式社区的博客端节点,欢迎加入下一代社区网络

♏ Vditor - 一款浏览器端的 Markdown 编辑器

HTML 中可以包含多个 `<header>` 或者 `<footer>` 元素吗?

2018-12-16

回答

当然可以。W3 文档指出 <header><footer> 标签表示离他们最近的祖先“段落”区域中的头部和页脚。因此不仅 <body> 可以包含头部和页脚, <article><section> 同样也可以。

加分回答

W3 建议根据你的需求编写你所需要的 <header><footer>,但是他们在离他们最近的祖先“段落” 中仅能出现一次。

正确示例

<body>
    <header>...</header>
    <section>
        <header>...</header>
        <footer>...</footer>
    </section>
    <section>
        <header>...</header>
        <footer>...</footer>
    </section>
    <footer>...</footer>
</body>

错误示例: body 中出现两个 <header><footer>

<body>
    <header>...</header>
    <section>
        <header>...</header>
        <footer>...</footer>
    </section>
    <footer>...</footer>
    <header>...</header>
    <section>
        <header>...</header>
        <footer>...</footer>
    </section>
    <footer>...</footer>
</body>

返回总目录

每天 30 秒


欢迎注册黑客派社区,开启你的博客之旅。让学习和分享成为一种习惯!

留下你的脚步