HTML5 introduces a whole bunch of new elements. The first ones I’ve looked at are the markup elements — those used to organise the content of a document or the text within it. Look under the hood of many pages and you’ll find that the page navigation is contained within a div
often with an id or class named “navigation” or “nav”. There’ll be similar div
elements for the main body, sidebars, footers and so on. Many of the new elements will be used to replace these non-semantic div
elements. With HTML5 we now have semantic navigation
, article
, aside
and so on. The rest appear to be a mixed bag that can represent data “types” or group together related content and for now at least, are largely unsupported by browsers. Anyhow, without further ado, on with the show…
section & article
These two tags appear to be responsible for the most confusion and arguments, largely because they are so similar. They’re both used for grouping related content with article
defined as being for “self contained” content. To me, the section
element has a more generic name and can therefore be used in more situations whereas article
has a more specific name and therefore more specific use. It’s a very simplistic way of looking at things, but right now, it helps me think out where I might use them. e.g. in a blog, you might have a section
around the main body of content and within that, each post would be an article
. You might also use a section
within an article
to contain the comments (though maybe they should be an aside
?)
One of the best explanations I’ve seen comes from Jean Galea who says
Think of a newspaper. The paper comes in sections. You have the sports section, real estate section, maybe home & garden section, etc. Each of those sections, in turn, has articles in it. And, some of those articles are divided into sections themselves.
What I’m now wondering is how you differentiate section
from the good old div
? The way most people are looking at it, div
conveys no meaning and is just used to group together other elements for purposes of styling. A variation on this was that a section
should (or could) have a title whereas a div
is just for blocking off a bit of content. I reckon if the div
element had been called division
I’d probably not be writing this now…
aside
The aside
element is used “for content that is tangentially related to the content around it” and it looks like it will be mostly used for marking up sidebars. However, in the context of an article
it can be used for related reading, glossaries and so on and in fact, this was the original purpose of the element. Basically, it’s for stuff that is nice to have but that you can safely ignore. e.g. as I mentioned above, I think that for a blog post, comments could be placed within an aside
.
header & hgroup
The new header
element is used to group together related heading elements. For a web page, this will usually be the stuff at the top of the page and might include the sites name, maybe a tag line, some navigation etc. Within an article
(e.g. a blog post) it might contain the title plus additional meta data such as the author and date/time published.
There’s another new heading related element. The hgroup
element “is typically used to group a set of one or more h1-h6 elements — to group, for example, a section title and an accompanying subtitle”. There’s some examples of how to use hgroup on the HTML5 Doctor site but to be honest it still doesn’t make much sense to me. They use a hgroup
to group together an article’s title with its “subtitle”. The problem I have is more to do with the use a h2
element for a “subtitle”. I doubt that there’s anything wrong with that, but to me, h2
s are for a second level of headings rather than a subtitle. I suppose if you are going to use h2
for a subtitle then grouping them together with a hgroup
element at least shows the author’s intention but why not just wrap it in a header
instead? It’s good to see I’m not alone and that people far more knowledgeable than me are also wondering about this.
There seems to have been a lot of to-and-fro’ing over the inclusion of hgroup
in the HTML5 spec. For now at least, it appears to be in but I’m not sure if I’d ever use it.
footer
The footer
element seems pretty simple and unambiguous. It’s for stuff that comes at the end of a document or section
or article
. On a web page, the footer usually contains some navigation elements, some credits and other flotsam and jetsam that needs to go somewhere. For a section
or article
(e.g. a blog post) it might be tags, categories and so on.
nav
The nav
element is used to identify “major navigation blocks”. What exactly constitutes “major navigation” seems to be left to interpretation. It sounds like the navigation found at the top of most web pages would be a dead cert for the nav
element as would secondary navigation — the sort you usually find at the top of a left or right hand side bar. The spec makes an example of the navigation you often find in a site footer (to copyright and terms of service pages etc) as navigation that doesn’t need to be wrapped in a nav
element. Other possible uses could be for table of contents, breadcrumbs, pagination and so on. I suppose it’s for the navigation that people use on a the day-to-day basis to get around a web site.
mark
The mark
element is intended for “text that should be highlighted”. The spec adds:
When used in a quotation or other block of text referred to from the prose, it indicates a highlight that was not originally present but which has been added to bring the reader’s attention to a part of the text that might not have been considered important by the original author when the block was originally written, but which is now under previously unexpected scrutiny.
How does this differ from strong
or em
? My take is that mark
is more ephemeral — that it is used for highlighting text that is important for the user right now, but might not be important the next time they visit the page. A simple example of where it might be used would be to highlight search terms.
figure & figcaption
The figure
and figcaption
elements appear to be fairly straightforward and are intended to “mark up diagrams, illustrations, photos, and code examples”. You use figure
to group together an image and a caption as a single logical entity with figcaption
used to mark up the actual caption. As with most of these elements, it seems that there’s been a bit of discussion about exactly how this should be done. In this case the discussion centred around how the caption should be marked up — should an existing element be used or should a new one be created. In the end, it looks like they’ve gone with the latter option.
And the rest?
There are a few other new elements such as time
and ruby
but they don’t have much in the way of support at the moment and I’m not even sure if they’re finalised or whether there’s still some arguing to do yet. As such, I’m going to move on to other things. Next up, the new HTML5 form elements…
Some Links
I found these useful whilst writing this…
Dive into HTML5
W3C Schools List of New Elements
HTML5 Doctor
W3C HTML5
Comparison of Browser Support
And here are a couple of gallery/example sites…
http://html5demos.com/
http://html5gallery.com/