HTML Guide for footer
The <footer> element represents a footer for its nearest sectioning content, and has an implicit role of contentinfo, so specifying this role is redundant.
The following example marks a <div> as a footer specifying its role:
<div role="contentinfo">
<h2>Footer</h2>
<!-- footer content -->
</div>
Using the <footer> element instead is recommended:
<footer>
<h2>Footer</h2>
<!-- footer content -->
</footer>
A <footer> can’t include other <footer>s inside.
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.
A <header> section can’t include any <footer> section inside.
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.
Footers don’t necessarily have to appear at the end of a section, though they usually do. In any case, they can’t go nested inside a <header> section.
A header element cannot be placed inside a footer element according to the HTML specification.
The header and footer elements are both considered “sectioning” content in HTML. The footer element represents the footer for its nearest section or the body, while the header element represents introductory content or navigation links for its nearest section or the body. The HTML specification prohibits nesting a header directly within a footer as it doesn’t make semantic sense—footers are for closing or supplementary content, not introductions.
Invalid HTML Example:
<footer>
<header>
<h2>Footer Header</h2>
</header>
<p>Some footer content here.</p>
</footer>
Valid HTML Example: Move the header element outside of the footer element.
<header>
<h2>Site Header</h2>
</header>
<footer>
<p>Some footer content here.</p>
</footer>
If you need a heading inside the footer: Instead of using a header inside footer, use heading elements (h2, h3, etc.) directly within the footer.
<footer>
<h2>Footer Section</h2>
<p>Some footer content here.</p>
</footer>