<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

瀏覽器相容性

另見