This is an update from the previous article since the spec has changed to allow
footer to have the same content model as
When I wrote the previous version of this article a few months ago, I knew, as I’m sure many of you also knew, that this element in particular would be subject to change as the HTML 5 spec neared it’s completion. The problem was simple, the
footer element just didn’t feel 'complete', it just didn’t offer the same flexibility as other elements. Now that’s changed.
In summary, the content model for the
footer element has been changed to allow sectioning content like
header or like
nav. In fact it now works in very much the same way as the
header element. However, it’s important to note that
footer isn’t sectioning content and doesn’t introduce a new section.
If you’ve been working on a site and have incorporated a wonderful new footer with everything that it now allows please feel free to post a link in the comments to show other readers just what you can get away with.
Below is an updated copy of the original article.
For some time now we’ve become accustomed to seeing
<div id="footer"> at the bottom of web pages but with the introduction of HTML 5 it’s time to say goodbye. With the addition of the new
<footer> element we now have more scope and flexibility.
According to the spec
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.
Lets get started
Before we get stuck into dissecting the new element, let’s lay the foundations for the article and cover the basics. As we’ve already mentioned above, most people would have laid out the footer as follows
<div id="footer"> <ul> <li>copyright</li> <li>sitemap</li> <li>contact</li> <li>to top</li> </ul> <div>
However with the creation of HTML5 this is no longer the case. As you may already know, there is now no longer the need for the
<div> element for many elements. In our case, when referring to the footer, the appropriate markup would be
<footer> <ul> <li>copyright</li> <li>sitemap</li> <li>contact</li> <li>to top</li> </ul> </footer>
As I mentioned in the first paragraph, originally the
<footer> element was only utilised once within our pages but with the introduction of the new element, this no longer needs to be the case. The
<footer> element can now be used multiple times and to display all the extra information.
Using the footer element
An important point to note is that you are not restricted to use one
<footer> element per site, you can use multiple footers, each of which will then become the
<footer> for that section of the document. You could therefore have a
<footer> for a
<section> or an
<section> Section content appears here. <footer> Footer information for section. </footer> </section>
<article> Article content appears here. <footer> Footer information for article. </footer> </article>
To see an example of the
<footer> within an article/section look no further than this very page. Scroll down beyond the article and you will notice the light grey text section, which falls directly after the “further reading”. This grey text section which gives information about trackbacks, responses, tags and categories is infact using the footer element.
We’ve already outlined what the new footer can look like above.
I was initially thrown off-course by the presentational name of the element; my use here isn’t at the bottom of the page, or even at the bottom of the article, but it certainly seems to fit the bill – it’s information about its section, containing author name, links to related documents (comments) and the like. There’s no reason that you can’t have more than one footer on page; the spec’s description says “the footer element represents a footer for the section it applies to” and a page may have any number of sections. The spec also says “Footers don’t necessarily have to appear at the end of a section, though they usually do.”
The footer element offers the chance to define web pages giving them the correct semantic mark-up that they deserve but it’s vital to use these new found tags as they were intended for. Let’s not get carried away and misuse this tag like we have done with tables and divs.