Understanding <aside>

HTML 5 offers a new element to mark additional information that can enhance an article but isn’t necessarily key to understanding it. However, in the interpretation of <aside> there lies confusion as to how it can be used, and with that there is demand for the Doctor to step up and clear the air. In this article I will look at what <aside> was created for, including sample uses and how not to use this useful, misunderstood element.

First, a look at how the HTML 5 specification defines <aside>:

The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. Such sections are often represented as sidebars in printed typography.

What can often trip-up someone reading the specification is the use of the word “sidebar”. I will go into detail about this later in the article, for now you should be aware that what is said there might not quite mean what you first think. Content within an <aside> should be stand-alone information that is related to the article in context. If your <aside> content meets this requirement, then you have a useful element to not only semantically wrap that content but to even hook CSS styles on.

How strict should this relationship be? Very. Good <aside> content examples include pull-quotes, a glossary or even related links.

Example Uses

As suggested in the specification, a pull-quote is an excellent example of a piece of content that is separate from the main article body but still related. Points of interest highlighted.

<article>
    <header>
        <h1>Lorem Ipsum Dolor Sit Amets</h1>
    </header>
    <p>Aliquam erat volutpat. Vestibulum eleifend pellentesque urna, at
    sodales est faucibus sit amet. Praesent in mi dui. <q>Aliquam sed
    bibendum nisl. Mauris pharetra enim sit amet ipsum dictum placerat. Sed
    lacinia pulvinar iaculis. Nam sit amet hendrerit purus.</q> Sed a urna
    laoreet lorem pulvinar fermentum. Aenean vel luctus libero. Ut tincidunt
    metus sagittis ante viverra feugiat.</p>
    <aside>
        <q>Mauris pharetra enim sit amet ipsum dictum placerat.</q>
    </aside>
    <p>Nulla quis lacus non quam luctus vestibulum. Pellentesque imperdiet
    risus gravida ante consectetur fermentum. Vivamus et est nec risus volutpat
    elementum. Ut faucibus, lectus consectetur volutpat dapibus, quam diam
    luctus enim, vitae mollis enim purus non ante.</p>
</article>

For more about the <header> element see Richard’s article, “The <header> Element.

On a styled web page or, more common, in a printed article this would be represented visually as a highlighted quote to the side of the main article. This <aside> is related to the content but does not need to be part of the article body as it can be understood without the extra information, or in this case without the duplicate quote.

Another example would be a glossary of terminologies used in an article:

<article>
    <header>
        <h1>Web Technologies</h1>
    </header>
    <p>Curabitur dignissim lorem a CSS diam posuere tempor. Nam hendrerit,
    eros vel condimentum tempor, ipsum justo cursus justo, quis vestibulum
    turpis turpis sit amet tellus. Quisque quis PHP magna eget ipsum faucibus
    bibendum at non diam. Sed sapien est, cursus ac ullamcorper id, egestas vel
    urna JavaScript. Nullam aliquam dolor vitae quam pharetra auctor.</p>
    <aside>
        <dl>
            <dt>CSS</dt>
            <dd>A set of standards for styling documents presented on the
            World Wide Web.</dd>
            <dt>PHP</dt>
            <dd>A server-side scripting language suited to dynamic HTML document
            generation for the web.</dd>
            <dt>JavaScript</dt>
            <dd>A client-side scripting language used for manipulating HTML documents
            within a browser.</dd>
        </dl>
    </aside>
</article>

Incorrect use of <aside>

It is easy to confuse this element for something it isn’t, and as mentioned earlier the definition of <aside> can trip-up a few developers. The most common misconception of how this element should be used is for the standard sidebar. While there is usually a degree of relation between sidebar content and the content in an article, it is not enough to be considered fit for an <aside>. Navigation, ads, search boxes, blogrolls and so on are not directly related to the article and therefore do not justify the use of an <aside>.

In the definition of <aside> it is key to note that it refers to sidebars in printed media, such as a magazine or leaflet. A “sidebar” in a magazine might contain additional notes on the article in context, translating this to HTML 5 would consider this an <aside>. If the printed article on PHP had an ad for “Superior, Cheap, Web Hosting” as a sidebar, this would not be classified as an <aside>. In such cases, look at other elements for more semantic mark-up.

Closing Thoughts

Like any HTML element, when used correctly the <aside> element can be very useful in semantically marking-up page content. An <aside> can be used to enhance an article with additional information, or highlighting parts that the reader may find interesting. Asides are stand-alone, non-essential as part of an article but when used correctly it can be an extra level of information for your content. Don’t try to force content into an <aside>, if it’s not tangentially related to the article then it shouldn’t be there. HTML 5 offers many new elements to mark-up your web pages, use them wisely.

This article was written by Mike Robinson. A developer at Lift in Reading, England, you can catch him on Twitter or occasionally blogging on his own site, akamike. Beyond the web, Mike is usually gaming or listening to progressive rock.

Posted on

Got anything to add or ask? then leave a response,
or trackback from your own site.

Categorised under: Elements.

Tagged with: , .

12 Responses to “ Understanding <aside> ”

Comment by Rich Clark at

I understand your concern and thats exactly why we’re going to try and address that issue. There are issues with the perceived differences (or lack of) between figure and aside for example and our very own Bruce Lawson has written to the working group to get clarification, we’ll do our best to keep you updated with developments.

Comment by Stuart Charlton at

In your first example, what is added to the document by wrapping the h1 in a header element? And what is gained by using aside over blockquote for the pull-quote?

Comment by John Allsopp at

I agree with Jason that this, along with other aspects of HTML5 will likely cause confusion, and attendant misuse. In english, an aside means things at odds with the definition in HTML5. And apart from Matt Mullenwegg’s asides in wordpress, I’ve rarely if ever seen it used in relation to publishing and document markup.

The idea is very sound, The implementation is problematic, sadly.

Comment by Scott Nellé at

In your first example might not the duplication of the quote be confusing from an accessibility standpoint because it presents information out of context and breaks up the flow of information around it? I think this is probably most jarring for screen reader users. Are there any plans that you’re aware of to address context issues with the element?

Comment by John Faulds at

In such cases, look at other elements for more semantic mark-up.

Can you give some examples of elements in HTML5 that would be better suited to marking up sidebars (the common web type, not printed)?

Comment by Bruce Lawson at

In the skeletal sample markup above, there is no advantage to wrapping the h1 – but as most sites have a tagline, some nav, a logo etc the header groups them more semantically than div id=”header”.

Sidebard are frequently used in print material as “related reading” or “if you liked this, you might like that” and I would mark those up with aside.

For pullquotes, you might also consider the figure element, and set the aural stylesheet for display:none (if any screenreader ever used an aural stylesheet, of course)

bruce

Comment by D Ross at

Ok..So don’t use aside for the sidebar. Then what to use? Should this not be clearly stated in the article?

Comment by D Ross at

Hmm…I’ve been researching and reading more about aside the last hour or two. It seems very awkward to wrap DLs/Qs etc in aside. A DL or Q already has enough semantic meaning on it’s own and, IMO, does not need to be double wrapped and double “semanticized” :) .

I see what they’re saying about the aside directly relating to the article or content but a sidebar does relate to the “content” of a website. It is secondary information for that page as a whole.

I’m about to start writing my first html5 site and am going to use aside for the main sidebar. If, after delving deeper, it turns out ugly or I find a better solution I’ll repost.

I could use “section” but if you use “section” for every area of the page then what’s the difference or benefit over div really? Not a whole lot.

aside sets secondary “page” information to the side. That’s what I’m going to use it for.

Comment by D Ross at

Yep, aside as the entire sidebar doesn’t work. At least not in my case where I have different sections within the single aside. Damnit. Guess I’ll use section!

Seems like there should be some sort of explicit tag to identify an entire sidebar as a sidebar and merely not just a section.

Comment by Scott Nellé at

I’ve been doing some cursory investigation into HTML 5, and from what I can tell section is a decent candidate for a main sidebar. However, as D Ross says above:

I could use “section” but if you use “section” for every area of the page then what’s the difference or benefit over div really? Not a whole lot.

I tend to agree with that. How about footer? You’re allowed several per page, and it’s meant to represent the footer in a semantic sense (so to speak) where we usually put info about the page, extra navigation, etc… To me, this serves essentially the same purpose as a traditional main sidebar. Therefore, I’d suggest the footer element for the main sidebar.

Comment by Mike Robinson at

@John Faulds & D Ross: It really depends on your sidebar’s content. For example, if your sidebar contained a list of categories that link to their archives, the nav element would be appropriate. If you feel the need for additional semantic grouping of these elements in your document, use div, article, header, footer or section as appropriate.

In regards to the question about use of section and div, this is something that could be covered here at HTML5Doctor as it appears to be a concern of many developers/designers.

Leave a Reply