Aside Revisited

This is an update from the previous article since the spec has changed to allow aside to be used for secondary content, changing it's context depending on whether or not it is contained within article.

As the HTML5 specification is not yet final, changes should be expected in order to improve on the good bits and cut out the bad bits. aside, a misunderstood good bit, is such an element that has had another look and tweaked based on feedback from the web development community. In this article we take a look at what has changed.

Doctor! Doctor! I feel like I’ve read about this before!

Here at HTML5Doctor we have indeed already discussed aside in “Understanding Aside“, and if you have met me in person you’ll have likely been hit by my ranting about its definition. Its definition suggested that aside should be used for content that was tangentially related to the content surrounding it, such as related reading links and glossaries.

It did not appear to be an appropriate element for holding secondary content, typically known as “sidebars” which contain content related to the site, rather than related to the specific article. From the comments here and elsewhere, you can see this definition was not accepted by the community, and opened the debate of “what should we use for secondary content?”.

Aside Redefined

Aside is now acceptable to use for secondary content, such as a blogroll, groups of additional navigation and even advertising if that content is related to the page. When used within an article element, the contents should be specifically related to that article, for example a glossary. When using aside, please be aware of these changes of context.

The two uses of aside can be best illustrated with an example.

<body>
  <header>
    <h1>My Blog</h1>
  </header>
  <article>
    <h1>My Blog Post</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
    eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    <aside>
      <!-- Since this aside is contained within an article, a parser
      should understand that the content of this aside is directly related
      to the article itself. -->
      <h1>Glossary</h1>
      <dl>
        <dt>Lorem</dt>
        <dd>ipsum dolor sit amet</dd>
      </dl>
    </aside>
  </article>
  <aside>
    <!-- This aside is outside of the article and is therefore content
    related to the page but not as tightly to the above article -->
    <h2>Blogroll</h2>
    <ul>
      <li><a href="#">My Friend</a></li>
      <li><a href="#">My Other Friend</a></li>
      <li><a href="#">My Best Friend</a></li>
    </ul>
  </aside>
</body>

Conclusion

This means that aside can now be used for secondary content. Please keep in mind that aside, and similarly secondary content, does not necessarily mean “sidebar”—the style of the content should not dictate the use of this element. If you have content which does not take as strong a role as your main content, but is related to the page or article, then aside is what you need, regardless of its visual design.

Share and Save:
  • Twitter
  • Digg
  • Sphinn
  • Reddit
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Netvibes
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • HackerNews
  • LinkedIn
  • NewsVine
  • SphereIt
  • Tumblr

30 Responses to “ Aside Revisited ”

Comment by Sidebar at

So everybody uses aside as a sidebar div and they’re all wrong.

Hmm, how about creating then a “SIDEBAR” tag so we can use that instead?

Comment by Kyle Fox at

For site-level stuff like blogrolls, advertisements, “about me”, etc., how do you choose between the <aside> or <section>?

For me it makes more sense to use <aside> tags exclusively inside an <article>, to give it proper context. I think it’s use-case is less clear now that it can also be used for secondary content.

What’s the purpose of adding all these new tags if they can be used all over the place interchangeably anyway?

Comment by kimblim at

Nice to see an actual example of aside in use – now it kind of makes sense ;)

Btw: You’ve got your definition list wrong – you’ve got a dd as the wrapper element instead of a dl…

Comment by Oli at

That’s a change? I thought that’s how <aside> always worked (?)

<aside> content should be additional to (but not essential to the understanding of) the main content, ie any related content … keep in mind the <aside> must be related—having your sidebar in an <aside> in the page’s main <section> is fine, but site-wide information shouldn’t appear in an article’s <aside>, for example.

An easy way to think about this is <aside> is related content that could be cut, eg by a mobile browser.

@Sidebar—no, it is possible to use <aside> for a sidebar, as long as it’s information tangentially related to the <aside>’s container. Read the article again ;-)

@Mike—maybe it’d be good to change:

Please keep in mind that aside, and similarly secondary content, does not mean “sidebar”

to “Please keep in mind that aside, and similarly secondary content, does not necessarily mean ‘sidebar’”, to avoid @Sidebar’s confusion.

@Kyle and @Rachel—The new semantic elements (mostly sectioning ones) can seem a little fuzzy, but that’s because they represent semantics, rather than one clearly defined thing, like an image or a list. Having an element for each specific context or use-case (rather than these more general-use ones) would definitely be a bad idea. While it takes making some HTML5 sites to get your head around, think Russian Dolls and you’ll have a head start.

Comment by Gerrit van aaken at

Now the question seems to be whether we should use more than one site-related “aside” element (one for each block in the sidebar, as a replacement for “div.sidebox”), or if aside can be used instead of a “sidebar” element.

Comment by Mike Robinson at

@Sidebar: “Sidebar” relates to the presentation of an element, rather than it’s content. Separation of content and presentation is vital, but to clarify: what you refer to as a “sidebar” is likely to be “secondary content”, and therefore <aside> is appropriate. Of course, if your “sidebar” is purely navigation that is key to the page, something like <nav> would be more appropriate. Presentation is irrelevant at the mark-up stage, so please refer to the content itself (”Primary Content”, “Secondary Content”, “Navigation”, etc) rather than how it could be styled.

@Kyle, Rachel, Gerrit & Sidebar: <aside> was originally called “sidebar” but was changed due to the presentational connotations with that name. How <aside> changes context depending on it’s parent elements is perfectly logical and is not the only new element that does so. For example, <header> and <footer> can exist directly in the <body>, in an <article>, or even in a <section>. The <header> of an <article> adopts a context that is dependant on that <article>, rather than the HTML document as a whole. Just like we don’t have a “subnav” element to differ from <nav>, adding an additional “sidebar” elment would be redundant.

@kimblim: Doh! Thanks for that, I’ve corrected the example :)

@Oli: Thanks for your great response! I’ve made that change, bit silly of me to miss it in the first place. In regards to how it used to be defined, there was nothing in the spec (particularly no examples) that deemed <aside> suitable for secondary content. Only recently was the third example of <aside>’s use added, along with this line:

The element can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of nav elements, and for other content that is considered separate from the main content of the page.

@Gerrit: It is acceptable to use multiple <aside> elements, particularly if you are grouping it’s contents by a particular theme. For example, an “Elsewhere” group of content that acts as a lifestream, plus a group of content directly related to the site (”Recent Posts”, “Tag Cloud”, etc).

Comment by Oli at

@Mike—Hrm, I’m now wondering if I read more into it than everyone else, or got some inside info on IRC. No matter! Hurrah for a more explicit spec eh :)

While I personally love the nuance the new semantic elements bring, they certainly seem to be easy to misinterpret huh :D Seems like the dust is starting to settle though

Comment by links for 2009-10-29 | Yostivanich at

[...] Aside Revis­ited | HTML5 Doctor “Aside is now accept­able to use for sec­ondary con­tent, such as a blogroll, groups of addi­tional nav­i­ga­tion and even adver­tis­ing if that con­tent is related to the page. When used within an arti­cle ele­ment, the con­tents should be specif­i­cally related to that arti­cle, for exam­ple a glos­sary. When using aside, please be aware of these changes of context.” (tags: html html5 w3c) [...]

Comment by Kyle Fox at

@oli @mike — I wasn’t suggesting a sidebar element. I realize that context is inferred by an element’s location in the DOM (i.e., the parent node gives a node it’s own context). Nor was I suggesting that there be an element for “each specific context or use-case”.

The point I’m trying to raise is that previously it was suggested to use a section element to identify auxiliary/secondary site-level content, perhaps like:

<section id="main_content"><article>...</article>...</section>
<section id="aux_content"></section>

whereas now it seems like and aside would be a more appropriate element to use for #aux_content.

My question, then, is how one would choose between section or aside when constructing this sort of markup, especially when considering that auxiliary content typically contains multiple pieces of content.

Comment by Dan Gayle at

This whole thing about “is it or is it not navigation/is it or is it not secondary content to the article” stuff is more confusing than ever. When does a website EVER have a “sidebar” without it having some kind of navigation? I completely understand the different use cases, and the idea seems close to what I do anyway.

For instance, I typically have a <div class="sidebar"> element that holds things navigational elements, ads, and other site-wide informational elements.

Within my <div class="content"> block, I sometimes have what I refer to as an “inline sidebar”, <div class="inline-sidebar">. This inline sidebar does indeed work specifically in the manner in which you describe how the <aside> element should work.

If constrained to that use, it would make a lot more sense, particularly when it comes to parsing, such as your mobile device example. What happens when we web designers, confused by the switching context of these stupid elements, decide to make our <div class="sidebar"> elements into <aside> elements, and the user agents of our mobile devices parse that out, as you suggest?

The whole “semantics” thing is getting way out of hand sometimes. If you do a survey and everyone calls the same element “sidebar”, and you decide to create an element to take up its role, but “oh by the way, it doesn’t do what you think it does and we’re going to call it something else” is a stupid, stupid mistake.

Comment by Dan Gayle at

And I thought that this might be appropriate:

side·bar (-bär′)noun1. a short article dealing with a sidelight of a major news story and printed alongside it2. a discussion at the bench between the lawyers and the judge, conducted outside the hearing of the juryYourDictionary.com/sidebar

I come from a newspaper background, and I have always thought of a sidebar in this manner. It has nothing to do with the presentation.

Comment by thinsoldier at

Idea for future article:
Take a screenshot of a real site (I can supply one :)
Discuss the original html4 tags & id/classes used.
Then you guys label the screenshot with what html5 tags & id/class values would be best and why.

Comment by thinsoldier at

Continuing thought:
Seriously, this site needs more screenshots/visual aids of real-world examples. None of that bare-bones grey-box example junk.

Comment by Richard Clark at

@thinsoldier good points, and glad to hear your thoughts, this is actually something we’ve got in the pipeline but we were thinking of guiding people through the process by writing the markup as well. We’ll try and add some more real world examples in the future. If you’ve any other thoughts be sure to let us know.

@dangayle

If you do a survey and everyone calls the same element “sidebar”, and you decide to create an element to take up its role, but “oh by the way, it doesn’t do what you think it does and we’re going to call it something else” is a stupid, stupid mistake.

Thats exactly what Hixie did (well not a survey but he profiled a tonne of sites for class and id names) and it’s why we’ve got elements like header and footer. I’ll try and find the link for you.

Comment by Dan Gayle at

Thats exactly what Hixie did (well not a survey but he profiled a tonne of sites for class and id names) and it’s why we’ve got elements like header and footer. I’ll try and find the link for you.Richard Clark

That’s exactly my point. Why go 3/4 of the way and use nomenclature that web designers understand, then attempt to replace something they do understand with something that a) is named funny and b) doesn’t even work the same anyway?

You have now introduced confusion where confusion need not exist.

Try this on:

side·bar (-bär?)
noun
1. a short article dealing with a sidelight of a major news story and printed alongside it
2. a discussion at the bench between the lawyers and the judge, conducted outside the hearing of the jury
YourDictionary.com/sidebar

Semantics indeed.

Comment by Alohci at

@bruce. Interesting list. Some comments:

1) The class names “main”, “body” and probably “content” don’t map exactly onto the “article” element’s semantics. In fact, article is explicitly disallowed from acting as “main” or “body”.

2) The “date” element seems to have disappeared in favour of the “time” element. The class name “time” is not listed.

3) None of the class names “section”, “article” and “aside” appear at all.

Neither do they appear in Rene Saarsoo’s survey (http://triin.net/2006/06/12/CSS#class-selectors) or John Allsopp list of classes (http://westciv.typepad.com/dog_or_higher/2005/11/real_world_sema.html Table 3).

Little wonder then, that there is so much confusion about how to use these elements correctly, since it seems that they are not achieving their original intent of “paving the cowpaths”.

Comment by bruce at

@Alohci

1) true. But this research shows the origin of the idea of document landmarks becoming elements in their own right.

2) I should have said – this is from December 2005. Spec has changed quite a bit since then.

3) section is from xhtml2. article – as the main content of the page – is easily discernible as an attempt to make a generic element that encompasses main / content/ body. Aside seems (to me) to be an obvious addition to “landmark” elements. YMMV, of course.

Re Saarsoo/ Allsopp lists – pass. Maybe Hixie will stop by and answer.

Comment by Zygmuś at

HTML 6 will have also tags: “undecided”, “internetexploreronly” and “waterclosed”. Sorry pseudo webmasters loved in “beautiful desgin build with XHTML 7 Nitro Edition + CSS 9″, but I am switching… back: to the HTML 3.2 Final. I can still use with it: CSS 1-3 and ECMA libraries/extensions like jQuery. HTML>4.01 Strict just does big suck. I will never support special html-fixations for iPhones etc. I do not care for guests/users working with this kind of device. It is not my problem, but their. In fact, Internet Explorer users will have always support, becouse you have to care for them. If you will not support them (even by making websites layouts based on tables) your site will means nothing to the whole wide world.

Comment by Mike Robinson at

@Zygmuś: You clearly have a lot of issues with the way HTML is heading, but I am not sure how your comment relates to this particular article! It might be more worth your time to republish that on something more relevant.

Comment by TomkOx at

Someone said (in prev-version of article) that for image should be used <figure> instead of <aside>. But it is not true! Reason: if image is “just an ad-on relative to the main content” it can be put into the <figure> and this “figure” can be inserted into <aside>.

Comment by Keri at

As the definition of has changed the implementations in the leading edge browsers will need to change, and that will take time. I’m waiting until at least one browser announces support for the new definition before I do any more HTML5 testing.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <b> <blockquote cite=""> <cite> <del datetime=""> <em> <i> <q cite=""> <strong>

You can also use <code>, and remember to use &lt; and &gt; for brackets.