Updated 22/01/2014 by Dr. Steve

We doctors are a bunch of chums using HTML 5 and writing about how we do it. Apart from spurious requests for medical advice, the questions we receive most are about using the section element, and we realise that we’ve been using the section element incorrectly all this time.

Sorry.

What we’ve been doing wrong is using section to wrap content in order to style it, or to demarcate the main content area from the nav , header , footer etc. These are jobs for div , not section .

The section spec says

The section element represents a generic document or application section…The section element is not a generic container element. When an element is needed only for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element’s contents would be listed explicitly in the document’s outline.

section is a blob of content that you could store as an individual record in a database. It generally looks like this (and note that the heading goes inside the section element, not immediately before it):

<body> ... <section> <h2>level of heading = section nesting level</h2> rest of the content </section> ... </body>

With very few exceptions, section should not be used if there is no natural heading for it.

The spec says

The theme of each section should be identified, typically by including a heading ( h1 – h6 element) as a child of the section element.

Check your work in the HTML 5 outliner tool. If you see any instances of “untitled section” that corresponds to a section, you’re probably doing it wrong. (It’s fine for a nav or aside element to be untitled, however).

Section is also the most generic of the sectioning elements. Make certain that you don’t really need an article , which is defined as

a complete, or self-contained, composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.

What about main content? Use the main element to mark up the main content area of a document. Dr. Rich Clark explains how to use The main element