<footer>:页脚元素

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

<footer> HTML 元素表示其最近的祖先 分节内容分节根元素的页脚。<footer> 通常包含有关该节作者的信息、版权数据或指向相关文档的链接。

试一试

<article>
  <h1>How to be a wizard</h1>
  <ol>
    <li>Grow a long, majestic beard.</li>
    <li>Wear a tall, pointed hat.</li>
    <li>Have I mentioned the beard?</li>
  </ol>
  <footer>
    <p>© 2018 Gandalf</p>
  </footer>
</article>
article {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

footer {
  display: flex;
  justify-content: center;
  padding: 5px;
  background-color: #45a1ff;
  color: white;
}

属性

此元素仅包含全局属性

用法说明

  • 使用 <address> 元素包含作者信息,该元素可以包含在 <footer> 元素中。
  • 当最近的祖先分节内容或分节根元素是 body 元素时,页脚适用于整个页面。
  • <footer> 元素不是分节内容,因此不会在 大纲中引入新的节。

无障碍

在 Safari 13 发布之前,contentinfo 地标角色并未被 VoiceOver 正确公开。如果需要支持旧版 Safari 浏览器,请将 role="contentinfo" 添加到 footer 元素,以确保地标能够正确公开。

示例

html
<body>
  <h3>FIFA World Cup top goalscorers</h3>
  <ol>
    <li>Miroslav Klose, 16</li>
    <li>Ronaldo Nazário, 15</li>
    <li>Gerd Müller, 14</li>
  </ol>

  <footer>
    <small>
      Copyright © 2023 Football History Archives. All Rights Reserved.
    </small>
  </footer>
</body>
css
footer {
  text-align: center;
  padding: 5px;
  background-color: #abbaba;
  color: black;
}

技术摘要

内容类别 流内容,可感知内容。
允许内容 流内容,但没有 <footer><header> 后代。
标签省略 无,起始标签和结束标签都必须存在。
允许父级 接受 流内容的任何元素。请注意,<footer> 元素不能是 <address><header> 或另一个 <footer> 元素的后代。
隐式 ARIA 角色 contentinfo,或者如果它是 articleasidemainnavsection 元素的后代,则为 generic,或带有 articlecomplementarymainnavigationregion 角色的元素。
允许的 ARIA 角色 grouppresentationnone
DOM 接口 HTMLElement

规范

规范
HTML
# the-footer-element

浏览器兼容性

另见