The truth about structuring an HTML5 page
Part polemic, part instruction manual, The Truth About HTML5 has ignited an interesting debate. Here we present an exclusive excerpt on the problems around structuring in HTML5
This is an edited excerpt from Chapter 3 of The Truth About HTML5 by Luke Stevens.
One of the most common tasks web designers do is mark up page structure, which usually consists of a header, footer, navigation, sidebar and content area. It’s the sort of thing you can probably do blindfolded and handcuffed to your chair after being spun around for five minutes.
HTML5 introduces a handful of new elements to help us define the structure of a given web page, such as <section>, <article>, <nav>, <aside>, <header> and <footer>.
We shouldn’t use them. They were made up on a whim by (probably) one guy in 2004 – and even he seems to have forgotten what their purpose is.
If that’s all you needed to know, great. Keep using divs with meaningful class and ID names, and appropriate <h1>-<h6> headings. They’ll be valid forever (more or less), and you’re not missing out on anything.
However, I suggest using some non-HTML5 features when marking up documents, such as ARIA attributes for blind and sight-impaired users and microdata schemas (when appropriate) for search engine results.
Nevertheless, we’ll tackle these new elements in depth because everyone gets them wrong. And we’ll set the record straight on how they found their way into the spec and their real intended purpose, which involves a radically different way of structuring your pages.
Advertisement
A little taste of pain
Here are just some of the problems these new structural elements introduce:
- They give terms web designers already use (such as header and footer) new uses, while claiming to be just doing what web designers are already doing.
- They introduce a new method of structuring documents that’s vague, complicated and unnecessary.
- They seriously hurt accessibility for some users (specifically those using IE6, IE7, and even IE8 with JavaScript switched off).
- They introduce broad, unclear, poorly-defined use cases that will make web standards harder to learn (and harder to teach).
These are serious problems that hurt, rather than help, web standards. Markup should be lightweight, easy to learn, and easy to apply. It should not require mental gymnastics to try and work out what to use where.
But these new structural tags have created a strange, quasi-religious experience where you have to consult the high priests (the HTML5 gurus) for their interpretation of vague religious texts (the HTML5 spec) just to mark up a darn web page.
“But, but... these elements are in the official HTML5 spec! Surely there must be a good reason for them?”
Read on...
Where did these elements come from?
Quiz question: How were these elements added to the HTML5 spec?
- Experts considered various use cases, weighed up various options and alternatives, and after extensive consultation and careful deliberation included the most important ones.
- The community of web designers and HTML authors (such as you and me) cried out for certain elements to enable particular functionality, and after much discussion the community came up with a shortlist of necessary elements.
- A scientific, research-based approach was taken, where markup patterns were studied 'in the wild' and codified into a bunch of new elements.
- Some markup wonks thought they’d be a good idea and threw them in the spec 7+ years ago.
And the answer is… (4).
“But I read in [insert HTML5 book of your choice here] that it was more like answer (3). The WHATWG studied real-world usage of ID and class names, and that’s how they came about!”
We’ll get to that.
I was intrigued about who added these elements, when they added them, and why. So I put those questions to HTML5 spec editor Ian Hickson, and here’s his reply (reproduced with permission):
"Me and other WHATWG contributors [added them], [in] 2004ish, because they were obvious elements to add after seeing how authors used HTML4. We later (late 2005 early 2006) did some objective research to find out what the top 10 HTML classes were and it turned out that they basically exactly matched the elements we had added, which was convenient."
You may have read about this 'objective research' in other HTML5 books, in talks on HTML5 or in blog posts about these new elements. But almost everyone fudges the history. Sometimes they say the research came first – it didn’t. Sometimes it’s just implied the research came first, which is still a sin of omission.
(Actually, according to the research in question, the major finding was that around 90 per cent of the billion pages sampled had no classes at all. If Hickson and the WHATWG truly followed the research here, they would have abolished classes altogether!)
So if these elements didn’t come about from research, where did they come from?
Exploring the dark recesses of the (thankfully public) WHATWG mailing list, I found Hickson first mentioning these elements in November 2004, when he discussed block level elements listed on his whiteboard.
In the same week he said “[W]hat I'm thinking of doing is [adding] section elements [that] would be: <body> <section> <article> <navigation> <sidebar>”. (You can see the full email here.)
Of course, somewhere along the way <navigation> became <nav>, and <sidebar> became <aside>.
So these new, major structural elements that everyone is trying to get their heads around were probably included because Hickson jotted them down on his whiteboard in 2004. They actually serve a much broader purpose for 'sectioning' (which we’ll get to shortly). But it’s worth establishing how they wound up in the spec, and how arbitrary they are.
XHTML 2.0 failed for being absurdly ambitious. In HTML5 we instead get a few semantic elements the editor drew on a whiteboard years ago on a whim, with some input from a handful of fellow WHATWG members of the time.
Who cares?
“Well, who cares?” you may think. “If the research ultimately supported using these elements, then what’s the big deal?”
The problem is that Hickson was, in my view, being a bit cheeky when he said these new elements “exactly match the elements we … added”. While they share the same name as elements commonly used, the spec describes their use in very different ways to what the web designers and authors would be familiar with. And for a standard these web designers and authors are supposed to use, that’s a big problem.
What happens when you take terms people use, redefine how they should be used (and even give them multiple uses), and then tell those same people not to worry because the terms are exactly what they’re already using? You put them on a one-way trip to confusion city.
The contradiction at the heart of HTML5’s new elements
HTML5 is supposedly about codifying what we’re already doing, or “paving the cowpaths”. When it comes to these new tags and marking up a basic template, they suggest you can just replace your current <div> structural tags with the new tags (for instance, replace <div id="header"> with <header>), and you’re done.
That was certainly the implication in the December 2007 ALA article 'A Preview of HTML 5', and the idea has been repeated in books and blog posts since, usually with a graphic like the underlying one here:
Swapping the new elements in for our old divs certainly looks easy, right? Nice, clean elements replacing a bunch of random divs, how lovely!
Unfortunately, there are few problems with this idea:
- Too few elements. There aren’t enough new elements to do a reasonable 1:1 substitution. Believe me, divs aren’t going anywhere. So if you hear anyone say, “Finally, I can get rid of my unsemantic divs!”, you have my permission to pop a cap in their ass with a Nerf gun.
- Not equal. While elements are often presented as being equal, they’re not. While the 'sectioning' elements (<section>, <article>, <aside> and <nav>) might work the same, the <header> and <footer> elements are intended to work within the sectioning elements. This can make a huge difference (as we’ll see shortly with document outlines), but if you followed most of the discussions about these elements you’d never know.
- Not a replacement. When you dig into the HTML5 spec, you discover these tags as described in the spec aren’t really meant to be 1:1 replacement for existing tags at all. They’re actually meant to be used for creating a new form of document outline. A document whatnow? We’ll explore this next.
These elements have other problems (they don’t add anything for semantics or search engines), but we’ll talk about them later when we take aim at those two zombie myths that just won’t die. We’ll also learn what 'semantics' actually means in markup, and what search engines really want.
Outline what now?
If you try to understand HTML5’s new structural elements without understanding document outlines, you’ll think they’re an arbitrary, oddly-named bunch of elements with confusing use cases.
However, once you understand document outlines, you’ll see they are in fact an arbitrary, oddly-named bunch of elements with confusing use cases that also have an overarching purpose of questionable value.
Granted, this is esoteric stuff. But bear with me and you’ll see how HTML5 tries to slip in a radical new way of doing something as fundamental as structuring a web page. This isn’t so much paving cowpaths as building a new bovine highway to nowhere.
What is an outline, and why should I care?
An outline is a sort of hierarchical, bullet-point representation of a document.
We actually make an outline whenever we mark up a document and use heading elements. So even if you’ve never heard of a 'document outline', chances are you’ve already made one. Weird, huh?
The reason we never hear about them is because web designers never have to use them. They’re mainly used by blind users as a primary means of navigation. When it comes to accessibility, outlines are a big deal. So the best thing we can do to help blind and sight-impaired users navigate documents is provide a good heading structure when using web standards.
HTML5 tries to radically change how we make these outlines … and maintain the existing way (well, kind of). This new approach to outlines is the reason the new HTML5 tags exist, and why Hickson and the WHATWG were thinking about adding 'section elements' in the first place.
How we currently create outlines (even without realising it)
Let’s back up a bit and look at our current outlines. In (X)HTML a document’s hierarchical structure was dictated through heading levels, using the familiar <h1> to <h6> tags.
So you might mark up your page like this (as a simplified example), with headings representing the 'importance' of each part:
The hierarchy or 'outline' for the document looks like this:
- 1. My Cool Site
- 1. Latest Posts
- 1. My Blog Post 1
- 2. My Blog Post 2
- 3. My Blog Post 3
- 4. Blog Sidebar
- 1. Blog Archives2. Popular posts
- 3. Blog roll
- 4. Blog Footer
- 1. My delicious links
- 2. My flickr photos
- 3. My social networks
Uh-oh. We have a problem. All our lower-level headings are 'owned' by the heading above them. 'Blog Sidebar' shouldn’t be a heading under 'Latest Posts' – it should start a new section.
If we changed the heading level of 'Blog Sidebar' to <h2> (the same as 'Latest Posts') that would give us:
- 1. My Cool Site
- 1. Latest Posts
- 1. My Blog Post 1
- 2. My Blog Post 2
- 3. My Blog Post 3
- 2. Blog Sidebar
- 1. Blog Archives
- 2. Popular posts
But now we’re no longer representing the importance of a heading. Instead we’re trying to build a logical structure using a limited set of tags (<h1>-<h6>), which have a habit of 'owning' everything below them – even when they shouldn’t.
Here’s another example. Let’s say we have a page that says:
In this document outline, the entire review would fall under <h3>Dislikes</h3>, because the heading 'owns' everything underneath it, even though it should really fall under <h2>My HTML5 Book Review</h2>. Usually this structural problem goes unnoticed. The visual problem of having the review text appear under Dislikes however would not go unnoticed, so for styling purposes we’d probably introduce a div so we can visually differentiate between the paragraphs under Dislikes and the review body itself.And indeed that’s often how we structure our documents – we use divs to break them up into logical sections. But this has no bearing on the document outline in terms of accessibility – the outline is created by headings alone.
As you can see, headings are flawed for creating outlines. People often use heading levels to display different font sizes (with or without CSS), or to indicate arbitrary 'importance' rather than structure. And sometimes they just cut and paste HTML straight into a new template.
When you consider all that, as well as the limitations of using <h1>-<h6>, it’s obvious that most web pages don’t have anything like a logical outline.
But they do have an outline, and using <h1>-<h6> at all gives blind and sight-impaired users a way to navigate our documents, which research shows is common for people using screen readers. (We’ll touch on that research in a moment.) So despite the flaws, for accessibility reasons we need to take headings-for-structure more seriously, not less.
(To see the outlines of any site (try your own!), check out the HTML5 Outliner for Google Chrome.)
But what if there was a way to create arbitrary outlines without relying on headings? As it turns out, people have been thinking about this for years – if not decades.
'Sectioning' is an old problem
The problem of headings, and how to structure a document, is a longstanding one. XHTML 2.0 proposed a solution in its first draft way back in 2002, which involved nesting <section> tags and using a generic <h> element for headings.
This 'sectioning' solution in XHTML 2.0 was initially mooted by Tim Berners-Lee as far back as 1991, as Jeremy Keith pointed out, when Berners-Lee said:
"I would in fact prefer, instead of <H1>, <H2> etc for headings [those come from the AAP DTD] to have a nestable <SECTION>..</SECTION> element, and a generic <H>..</H> which at any level within the sections would produce the required level of heading."
Yep, a good two decades ago.
HTML5 tries to bring this concept of sectioning into mainstream HTML by following a similar path to XHTML 2.0, while also maintaining some backwards compatibility. And the results are, shall we say, mixed.
But before we get to HTML5’s implementation, let’s look at just how important headings are for accessibility.
If we care about blind users we should care about headings
As we mentioned before, with HTML4 it’s headings such as <h2>Blog Sidebar</h2> (rather than random divs such as <div class="blog-sidebar">Blog Sidebar</div>) that create document outlines. And for blind users, these headings are important.
How important? In a survey of over 1000 screen reader users (where 80 per cent of the people were blind and 16 per cent were vision impaired):
"The responses to this question provided one of the greatest surprises to us. It is clear that providing a heading structure is important to screen reader users, with 76 per cent always or often navigating by headings when they are available. Use of heading navigation increased with screen reader proficiency with them being used always or often by 90.7 per cent of expert users, 79.3 per cent of advanced users, 69.9 per cent of intermediate users, and 55.4 per cent of beginners."
(You can see the full results here)
Were you aware of that? I wasn’t, and I’ve been using <h1>-<h6> willy-nilly for years. I imagine most web designers have some vague idea that <h1>-<h6> tags are important, but not how crucial they are for blind users.
So we had an established, straightforward, easy-to-implement way of providing outlines for blind and sight-impaired users. That is, until we hit HTML5.
HTML5’s 'improved' outlining was dead before it ever shipped
We’ve established what a document outline is (a bullet-point, table of contents-style representation of the page), and we’ve established how they are currently created (with <h1>-<h6> elements).
Here, in a nutshell, is how HTML5 proposes to create document outlines:
- Each bullet-point in the outline, or 'section', is defined using one of the four 'sectioning' elements: <section>, <article>, <nav> and <aside>; and not the <h1>-<h6> elements. The intent here is to solve the limitations of <h1>-<h6>.
- There’s no generic <h> element, as per XHTML 2.0. But in pure HTML5 it’s suggested we could just use <h1> everywhere as a generic heading element. In fact, any heading element in HTML5 will be treated as a generic heading, with its level determined by how deeply it’s nested in sectioning elements.
- But there’s no such thing as 'pure' HTML5 though, so we need to maintain backwards compatibility. Therefore we should still use <h1>-<h6> in a logical fashion, which means maintaining two somewhat different document outlines in the one document.
That’s the general idea. Here’s how the spec puts it:
"Sections may contain headings of any rank, but authors are strongly encouraged to either use only h1 elements, or to use elements of the appropriate rank for the section's nesting level."
Please don’t use <h1> elements everywhere!
In my view, everyone (Hickson in the spec and in public comments, standards advocates in the community, and designers and authors in general) has made a complete hash of communicating this.
This poor communication has meant that designers and developers have been using these HTML5 elements with no understanding of the outlines they have been creating. These elements were supposed to bring about better logical document outlines. Instead, given the haphazard way they’ve been implemented, they’ve created HTML5-style document outlines that are even more broken than the <h1>-<h6>-based outlines they were intended to replace.
HTML5’s version of outlining was effectively dead before anyone understood it, much less implemented it properly.
And here’s the irony: this approach, which may theoretically deliver accessibility benefits in the future (no one knows when, or even if, screen readers will use these outlines), is destroying the page styles for a small group of IE users now. So it’s already doing harm, yet has no clear future benefit.
Sneaking in big ideas leads to dead ideas
The first problem with this new approach to outlining is the idea that HTML5 is just “paving the cowpaths” and codifying existing practice.
Clearly, introducing a whole new way of structuring documents, however poorly communicated, is not “paving the cowpaths”.
You can’t then turn around and tell authors and designers, “This is what you’ve always done!” But Hickson has done just that, saying the new elements are just intended to save common class names. Here are just a couple of examples.
In 2009, Hickson said:
"They are, more or less, filling the most common requests from Web developers based on what the most common class="" attribute values are. Their main purpose is to simplify authoring and styling."
And in 2012:
"Mostly these new elements make authoring a bit easier."
So, if HTML5 is going to introduce a big new idea, it needs to communicate that big new idea. Instead, it appears Hickson doesn’t remember, or can’t be bothered arguing for, the big idea of sectioning he and the WHATWG added to the spec.
HTML5 advocates (and the spec itself) need to communicate the purpose of the new elements properly, or abolish them.
As it is now, they’re just inflicting nonsense on the web design community.
Let me give you an example.The spec says <header> and <footer> elements define areas within a section, but do not define sections themselves, and so won’t show up in a document outline. This is something most people get wrong, including those teaching HTML5 through books and blogs, whose examples often show <header> being on par with <section>. The spec also says <header> and <footer> can be used multiple times per page (once per section, for example), but you would never pick that up from most HTML5 resources out there.
These may seem like pedantic, wonkish points. But they illustrate something very serious – the community is trying to implement HTML5 markup in a way that doesn’t have much relation to the actual HTML5 spec. It’s a weird in-between state of markup limbo that has inadvertently appeared because that’s what everyone assumed these elements should be used for.
We forked the spec
In a sense, the community has forked HTML5, as far as markup goes. That’s a big problem. There’s the 'common (but incorrect) understanding' fork of HTML5, and there’s the actual HTML5 spec. But following the 'common understanding' and replacing visual areas in our templates with elements that 'sound about right' has no benefit for anyone. We just create a weird, broken outline while misusing the new elements. And with so many broken HTML5 outlines there, outlining as a concept is pretty much dead on arrival.
We’ll explore each element individually in a moment, but let’s stick with the big picture for now.
How should we structure an HTML5 page?
All this may seem a bit confusing at the moment, so let’s take a step back and look at the general rules of structuring a page in HTML5 (such as they are!), as described in the spec:
- We are supposed to use <section>, <article>, <nav> or <aside> to create a new section in the outline. (That is, a new bullet-point in the document outline.) You can see what your outline looks like with the HTML5 Outliner plug-in for Chrome. And yes, the terminology here is clumsy – having multiple elements, including <section>, create a section in the document outline is quite confusing!
- We use <header> or <footer> within each section to demarcate the header or footer of that section. That section can be anything from the root <body> section down to an individual comment. (An individual comment is supposed to be an <article>, as we’ll see in chapter four, which would create a section in the document outline.)
- We use heading elements (<h1>-<h6>) to give each section a title in the outline and provide backwards compatibility. (As I’m writing this there’s no meaningful support for HTML5 outlines anywhere, and doesn’t seem to be any on the horizon. So 'backwards' compatibility may actually be 'compatibility for the foreseeable future'.)
You might think you can just replace all your divs with <section>s and create an outline. However, <section>s aren’t to be used in cases where you only need a styling hook, so in a true HTML5 document you’ll still have plenty of divs. In fact, a 'correct' HTML5 document would have:
- a bunch of <section>, <article>, <nav> and <aside> tags to create the outline
- a bunch of divs for styling
- redundant use of <h1>-<h6> tags to duplicate the outline as best as possible (this is what screen readers will actually use)
- a healthy sprinkling of redundant <header> and <footer> tags within each section that don’t do anything.
Simplifying authoring? With two means of structuring a page, two outlines to maintain, and a bunch of redundant tags to add?
I don’t think so. And that’s before we even consider styling our headings.
Styling headings HTML5 style is kind of insane
Let’s imagine a pure HTML5 future where we can use <h1> everywhere as a generic heading element, as per the spec’s suggestion, and we use the new sectioning elements to create the outline. That is, if we use a <h1> three sections deep, it’s essentially a <h3>.
Let’s say we want to style this three-sections-deep <h1> as though it was a <h3>. How are we going to pick it out? And can you imagine picking h1 out everywhere through the cascade to give it a different style for different levels, given four elements can create a section, and can be used in any combination? You wouldn’t be able to sleep.
Nicole Sullivan touched on the madness that ensues when you try to style HTML5-style <h1> elements through the cascade in the appropriately titled blog post 'Don’t Style Headings Using HTML5 Sections' and gave this simplified example:
- h1{font-size: 36px}
- section h1{font-size: 28px}section section h1{font-size: 22px}
- section section section h1{font-size: 18px}
- section section section section h1{font-size: 16px}
- section section section section section h1{font-size: 14px}
- section section section section section section h1{font-size: 13px}
- section section section section section section section h1{font-size: 11px}
That, however, is the vastly simplified version, as Sullivan points out. The true madness sets in when you have to style all your (say) six-levels-deep headlines which may be nested in any combination of <section>, <article>, <aside>, or <nav>. For comedy value, see what such a style sheet would look like. It’s utterly insane.
The only option then is to fall back on class names for headings, but avoiding class names when authoring is the very 'problem' the WHATWG were trying to solve.
And do you think our clients and colleagues who happily create and edit web pages will ever understand the nuances of sectioning their articles correctly? I doubt it.
No wonder people are confused.
Oh, and to top it all off the styling of your <nav> (and any other new HTML5 elements) may blow up for ~1% of users.
This is the way of HTML5. And it’s a mess.
Not surprisingly, even the most experienced web authors get bogged down in the HTML5 outline quagmire. Read about Roger Johansson’s experience, for example.
This is not inconsequential – people have to teach this stuff
“OK, maybe the markup wonks got it wrong on this one. Maybe these tags are mostly redundant. So no one uses them, or they don’t do it quite correctly. Who cares, Mister Markup Pedant?”
The thing is, introducing these new elements – and concepts such as arbitrary outlining – into the official HTML5 spec means people actually have to teach this stuff. (Heck, some designers even teach their kids this stuff – see Cameron Moll’s cool HTML5 whiteboard magnets, for example)
This is bad for web standards. It makes even basic HTML hard to teach, hard to learn, hard to implement, and for what? Structuring a web page should be the least of our worries – not a huge distraction for a generation of students and professionals alike.
(A note to those teaching web standards: if you really hate your students, ask them to explain the difference between <article> and <section>.)
Where does this leave us?
Hickson and the WHATWG’s intentions are good. Theoretically, using these tags could improve accessibility even without considering outlining. (For example, screen readers could skip past the <nav> tag to get straight to the content.) But the vendors making screen readers have shown very little interest in HTML5 to date. And there is already support for better alternatives, which we’ll look at next.
So we don’t need HTML5’s new elements for accessibility. In fact, we should avoid them for the harm they cause another subset of users.
People will still use these tags, mostly because they want to 'do the right thing' in the hope the Standards Fairy will leave small change and/or an Apple product under their pillow. But it’s just a waste of productive time that could be better spent on more important things.
Remember: what ends up in the spec is often just the idea of a few (or even one) interested, smart, ordinary person from (as of writing) 7+ years ago. And chances are even they don’t remember why they wanted it. So I think we’re allowed to disagree about what’s best, and pick and choose what we implement.
But what happens to accessibility? Do we just leave visually impaired users with the status-quo? No, because fortunately there’s a better alternative.
A sane approach to structural markup for accessibility
There’s a way to add helpers for the blind and visually impaired in our markup without wading into the mire of HTML5’s new structural elements – ARIA roles.
Actually, it’s WAI-ARIA which stands for 'Accessibility People Apparently Don’t Do Catchy Acronyms'. Or, as sticklers for accuracy may tell you, it’s 'Web Accessibility Initiative - Accessible Rich Internet Applications'. (We’ll just call it ARIA.)
It’s not part of the HTML5 spec. Instead it’s a separate (and gigantic) W3C spec that’s compatible with HTML5, HTML 4 and XHTML 1.x.
The secret to ARIA is the role attribute, which can be added to an element like this:
- <div role="myariarole">
The full ARIA spec is big. Really big. But we’ll be looking at a small subset called landmarks.
As an example, here are the four main areas of a simple page:
- Header
- Content
- Sidebar
- Footer
And here’s how we’d mark it up using ARIA:
Easy.
ARIA benefits
ARIA roles have several benefits over HTML5 (or previous HTML versions):
- The roles generally reflect how web authors structure pages. (For example, the header, or 'banner' is for the stuff at the top of the page – not for every section on the page, as in HTML5.)
- They keep our markup relatively clean, because we can use the role attribute as a styling hook for IE7 and above with attribute selectors, such as div[role="banner"] {border:10px pink;}. (If you need to support IE6 users, you can also include redundant classes.)
- They work right now in screen readers that support ARIA landmarks, such as JAWS version 10 screen reader, NVDA 2010.1 and VoiceOver on iPhone IOS4+.
- They don’t blow up styling for IE6-8 users with JavaScript off like the new HTML5 elements do.
This technique can help blind users now, doesn’t hurt web standards, and doesn’t require getting your head around a second way of sectioning your document.
Layout recommendations
Before we finish, let me recap how I think we should mark up pages in the age of HTML5:
- We should not use the new tags. (But we’ll look at them next, and the ARIA landmarks we should use.)
- We should take headings more seriously, given how much blind and sight impaired users rely on them.
- We should use ARIA landmarks for accessibility.
- We should otherwise use divs with semantic class names or IDs like we’ve always done.




33 comments
Comment: 1
I've recently been rebuilding our corporate intranet, in a responsive and future-proofed way. What I found was that trying to use HTML5 elements in a logical way became very complex when dealign with wildly different content, services and applications across an intranet. That's even before dealing with shims to get IE7 to recognise these new elements.
In the end, I have ripped out the HTML5 elements and reverted to using div's with good class names, id's and ARIA roles as you've written here. It was the only thing that made sense based on adoption and support needs today.
Of course, I have made use of new HTML5 form attributes for placeholder and input types etc, which is a very useful and valid.
Comment: 2
Fits with a few thoughts I had about the new HTML5 elements, but I felt a bit like a black sheep on crazy pills for questioning it! :o)
Comment: 3
@timkeay Yes, we must always question these things! I really hope that, if nothing else, my book gets us thinking a bit harder about the specs that we end up working with day in, day out, and that from greater scrutiny better specs emerge in the future.
Comment: 4
Here is the reality: you are telling would-be readers and learners of web development that they should completely avoid using a specification that will become the standard. Readers, I urge you to use resources from W3C, Mozilla, Google and Microsoft (to name a few) in order to proceed with building your opinions and knowledge of HTML5 usage, the specification itself, and the future of structural web development.
http://www.w3.org/
https://developer.mozilla.org/en-US/
http://www.html5rocks.com/en/
http://msdn.microsoft.com/en-us/library/ie/aa740473.aspx
Op-ed pieces like this do nothing to help our industry. Opinion is one thing, detracting for the sake of book sales is another, and telling those looking to broaden their knowledge to avoid learning or implementing the official specification is just silly. They are the words of someone who has been "building web sites for over a decade" vs. the insights of individuals with many decades of experience in crafting products that are used by hundreds of millions of internet-goers per day.
To the author, please refrain from telling people to avoid using a specification. That's a terrible, terrible disservice to the progress of HTML as an open, ubiquitous markup language.
To the editor of the online edition of .NET magazine, this article is a shame, and I would have expected more scrutiny from you. Please promote articles that move the web forward, not OP-ED pieces that sell authors' books based solely on controversial, and in this case, detrimental viewpoints.
Comment: 5
But, I like that you suggest using ARIA roles to help assistive technologies. I'll definitely teach it as a good practice. Using them as style hooks... not so much.
Comment: 6
@atinker Well, indeed, but that's the issue with essentially forking the spec. If we use the elements from the spec, but in ways that contradict (or go beyond) how they are specified, then we've really created a whole new de facto standard, and either the official spec (or our usage) has to change.
Comment: 7
Regarding headings for document outlining, does anybody know of any kind of spec rule stating the use of and whether it's appropriate to use multiple 's in one piece of content?
This has always bothered me. Personally I've never done it, but I'm unaware of any spec rule about it?
Comment: 8
Comment: 9
The idea of document outlines seems natural to me, because I come from technical writing, where we've used structured authoring for ages, and where tools like FrameMaker punish you harshly for violating outline constraints. It sounds like web developers have been using heading elements in a less semantic, semi-stylistic way.
I agree that using all <h1>s in a handcrafted web page would be kind of insane. But what about content that is programmatically assembled out of a CMS? Particularly if content chunks are reused in multiple target locations, the content author has no way of knowing the exact outline context in which a chunk will appear. In that case, it seems appropriate to use a generic heading element and let the software figure out the sectioning levels. I guess the problem is that somebody still has to write the CSS for that system.
Comment: 10
The currently existing problem is that driving headers in from a CMS may bork the document outline if the headers are out of context on different pages.
The new elements would solve this issue.
As for selecting them with ultra-long CSS selectors like;
section section section section section section h1
Use a freaking class or ID?;
section.mySubContent h1
Comment: 11
http://html5doctor.com/the-section-element/
HTML5 is an attempt to improve the standards. It's also not fully complete or official yet. Can improvements be made? Most likely, but the thing to do there is make suggestions about how to improve it or what should be in the next incarnation of the standard rather than essentially just saying "this is crap - you shouldn't use it." I know of multiple issues with it I'd like improvement, but I know there is a system for this and I'd work through those channels first before going as far as you have. A book? O_o
Comment: 12
got the link from reddit /r/webdev
Comment: 13
Comment: 14
I simply believe that you are on the wrong path, and sadly, you are making a concerted effort to steer others onto that path as well.
If you are truly interested in making changes to the specification, please direct your energy away from self-aggrandizing book-publishing and place it in getting directly involved in the specification as an author.
http://www.w3.org/Consortium/join
Please prove yourself as a contributor, not just some critic with a rather shoddy opinion.
Comment: 15
Comment: 16
I largely came to the same (seemingly unavoidable) conclusions a while back: HTML5 Sectioning is simply too broken to work, and ARIA landmark roles are a much more elegant and useful way to navigate pages than HTML5 outlines could ever be anyway. Actually, I probably have an even more negative view of HTML5 Sectioning than the author does. It's just incredibly problematic for a whole host of reasons, and in my opinion Mr. Stevens was quite generous to HTML5 in this article.
- He didn't cover the problems with implied sectioning (sections created without an explicit sectioning element), which behaves in counter-intuitive ways, and can give unexpected outlines.
- He didn't cover the problems with anonymous sections (or sections without headings), which can bury content under unhelpful generic labels.
- He didn't cover the problems with sectioning roots, which effectively hide content from the document outline. (Note, even the venerable HTML 5 Outliner gets this mostly wrong per the spec.)
Unlike HTML4 and earlier, an HTML5 outline can break so badly it becomes all but unusable to navigate a page. An HTML5 outline does not necessarily reflect source order, easily can become heavily over-structured so as to bear more resemblance to a garden maze than a table of contents, and might not represent the existence of some content at all. But, people who use assistive technologies will still have a perfectly reasonable expectation that they will be able to navigate a page via the outline like they always have. I'm no lawyer, but I can't help but feel that this is an issue that has the potential to run smack up against accessibility laws. (Actually, I've never seen any discussion whatsoever about this ostensible accessibility feature of HTML5 and it's implications regarding current law. Does anyone know if there's been any discussion about that that I've missed?)
People can safely ignore the implications of HTML5 Sectioning for now, since nothing actually implements it. People seem to treat the subject like it's little more than just a few new block-level elements, like any other. However, if browsers and screen readers were to actually implement HTML5 Sectioning in it's current state, I feel that it's just so complex and misunderstood that it could be a disaster. And there's no way to identify and fix badly structured documents after they're written short of reviewing each piece of content and re-evaluating how each piece of content interacts with one another.
Millions and millions of web pages have been created based on a technology that developers don't really understand and can't reasonably fix, and we don't even know if someone can be successfully sued for getting it wrong. Call me silly, but I feel that makes it a topic worth at least some critical review.
~~Ian
Comment: 17
@P3tro The idea is, with the HTML5 outlining algorithm in effect, that the h1 element acts as a generic h element, and the algorithm determines what level it is based on how deeply it is nested in the outline. The spec says "Sections may contain headings of any rank, but authors are strongly encouraged to either use only h1 elements, or to use elements of the appropriate rank for the section's nesting level." (http://www.whatwg.org/specs/web-apps/current-work/#headings-and-sections). The alternative to using h1s everywhere, the spec suggests, is to use h5 if the nesting is five levels deep, h6 if it's six levels deep, and so on. Of course, this throws up all kinds of problems in trying to maintain a legacy and purely HTML5 outline in the one document.
@jmswisher @chrisbward Sure, an outlining algorithm isn't an inherently bad thing, just the way it's been implemented in HTML5. The styling issue is difficult to resolve though, because styling necessarily means you know what the level is of the item you're styling. You can of course apply classes, but this contradicts the stated, repeated goal of the HTML5 editor that this system is for simplifying authoring, not making it more complex. If you were to use classes and not style through the cascade, you would then have (a) a legacy outline for accessibility, (b) a HTML5 outline, and (c) a 'styling' outline applied on top of all that. It's messy.
@Basketcasesoftware Can you elaborate on which tag is misused in my example? Thanks. What channels are you aware of for improving the spec? I know of only one meaningful one: persuading Ian Hickson, the HTML Living Standard née HTML5 editor, and I can't say I've had much luck there :)
@thomasjbradley I discuss it further in the book and provide an example, but basically it goes like this: Say you style a nav element (for instance), and use the HTML5 JavaScript shim to help IE6-8 see the nav element and other HTML5 elements. When JavaScript is turned off, IE6-8 will still style the rest of the page, but not your nav element. This can potentially blow up your navigation -- as it did for a client's site of mine -- and make the site unusable for these visitors, i.e. inaccessible. (I'm using "accessibility" broadly, not just in terms of the visually impaired.) It's sometimes (dubiously) suggested that using nav, for instance, could theoretically help accessibility in the future, but I highlight the fact that in reality it does harm now for another subset of users.
@jsthomas That's fine if you don't read my book, but I strongly recommend you read a book -- any book -- on HTML5 aka the "living HTML standard", so you know how HTML is developed. These days it's not developed by the W3C, for one, so contributing there (were that possible) would prove to be a fairly futile endeavour. I think you'll be unpleasantly surprised when you see how the HTML sausage is made in the HTML5 age.
@riyadhalnur @sevenboards Well said :)
Comment: 18
The flaws you have pointed out are because the spec wasn't actually describing what we, people in the industry, are doing which is structuring documents to our domain specific needs and using tag attributes to define the "semantics". This is why the ARIA is successful and the HTML5 section is not. Standards bodies should not try to lead but only formalise what is already being done. Inovation has never, in the history of humanity, come from committee but from individuals on the front lines.
I've been in the game since 1996 and suffered though the hell of the browser wars so i know standards are a good thing, but in truth the section has no real meaning until Google decide to make it so. Lets face it, nobody marked up their documents "semantically" until suddenly you got better SEO for it. The consequences of something _are_ its meaning/semantic. Its a waste of time petitioning the standards guys, petitioning Google instead. This is the only thing that will lead to change on the web (like it or not).
Still, I would like to use the top level sections just to help break the DIV insanity that most pages have become, at least just for myself.
It also occurred to me that the nested sectioning styling problem could be handled with just 3 CSS rules. You just have to take into account that when using EMs the value is a percentage of the _parent_ element. So to get section headings that scale slightly smaller than section above them you just have to do something like: section { font-size: 0.9em } section h1 { font-size: 0.9em } p { font-size: 12px }
This last P style would be for content within the sections so they also didn't scale. Not a perfect solution but better than a dozen nested tags in the CSS. I guess CSS needs to be upgraded if the HTML5 sections are to work.
Comment: 19
Comment: 20
This illogicality comes from the fact that we were used to structure documents in a whole different way than HTML5 says we should. (multiple "headers" and "footers" on one page, say what now?)
Nice to see I'm not the only one questioning how these things came to be the new "standard". We'll have to see what the future brings though.
Cheers.
Comment: 21
in regards to channels to improving HTML5, the W3C HTML WG is the way to do it, things have changed somewhat since hixie is no longer HTML5 editor. Things are still shaking out, but the paths to change are there.
Comment: 22
I also pushed away from only using the html 5 doctype and not using the other tags where applicable. I reasoned it to someone putting on a firemans helmet, putting on his coat and boots. That still didn't make the person a fireman. The doctype alone isn't really using 'html5' in all it's supposed glory. Surprising how many mark themselves an expert in HTML5 and don't even use a tag.
Ahhh... as long as the intended message reaches the intended audience and is intelligible and understood, everything else (standards, best practices etc) is just for those who need to argue why their expertise is valuable so they feel important and rationalize why their job is necessary.
Comment: 23
1) Assuming I'm willing to completely and totally write off IE <=8 users who have javascript disabled (and I realize for some that's unacceptable), why not just use pure h1s for headings, like the spec says, and differentiate them for styling purposes with classes? (along with ARIA, of course.) This is the one part of your piece that doesn't seem well thoroughly explained. You just just say "please don't," which isn't enough for me. :) Why not?
2) It seems pretty clear that the grail of flexible document outlining would be an unnumbered h tag. We don't write li1, li2, li3, etc. So why do that for headings? (Among other things, it makes dynamically inserted content break the outline.) It's also clear that this would be a big leap that would break backwards compatibility in outlining. But the idea has been around for 20 years. So why hasn't it been implemented? What's the counterargument? And how do we get there from here?
Comment: 24
1) You might be conflating two different issues here. The IE6-8 no-JS issue applies to all the sectioning elements (nav, article, section, aside), and how they don't get styled in that particular circumstance for those users. That's a separate issue from whether you use h1 elements everywhere, or h1-h6, which affects visually impaired users with screen readers. You're quite right to say "please don't" isn't enough of an explanation :) but I do attempt to elaborate on the importance of a h1-h6 structure in the "If we care about blind users we should care about headings" section, I just obviously didn't link them very well! Screen reader users often navigate using the traditional heading structure, and giving them a huge, flat list of h1s seems like a bad idea to me, especially as HTML5 outline support is poor/non-existant in most screen readers. That's why the spec hedges and says you can try and do both (outline with HTML5 sectioning elements, and use h1-h6). Either way, you face a dilemma in how your support screen readers, which is discussed here: http://www.accessibleculture.org/articles/2011/10/jaws-ie-and-headings-i... . It's very unfortunate that that is the result of the HTML5's muddled implementation of outlines.
2) Why indeed! :) They key is "break compatibility". XHTML 2.0 was going to do that, and went nowhere. HTML5 claimed not to do that, but instead had a bet each way, attempting to introduce the new concept of sectioning while relying on existing heading elements. Unfortunately, by using the old elements in a new way, you... break compatibility (albeit to a lesser degree), and create a lot of confusion. How do we get to 'pure' document outlining without breaking backwards compatibility? I really don't know. That's the tension with something as fundamental as HTML - do we keep it forever, or do we try and reinvent it (ala XHTML 2.0)? Does technology move in such a way that it's permissible to create new requirements (e.g. we've made JavaScript mandatory for IE6-8 and HTML5 elements, why not do the same for something heading related?), or are we wedded to a base standard of HTML for maximum compatibility with all devices, old and new, forever? Moreover, who decides? At the moment, it's pretty much one man (and, ultimately, the browser vendors).
Comment: 25
I used the HTML5 layout tags on some projects but have now given up as I don't believe they add anything other making you look like a trendy web designer.
Ian Hickson always gets punched in the face but what I'd like to read is a riposte by somebody on the payroll of the W3C (http://www.w3.org/People/). That is, those people whose job it is to help facilitate and sell HTML5.
Comment: 26
Comment: 27
Hopefully we will see more sensible discussion on HTML5 to assist those of us struggling
Vix
Comment: 28
Comment: 29
Section tags are perfect for wrapping a group of entries that you would expect to stand out in your page, eg latest posts or news etc.
Each of these items would then sit in an article, which then has an optional header and footer. In the header and footer you can display the title/author/etc and a handy new tag for the time it relates to. I understand the header and footer may apply to other elements as well based on how they are nested, so a page could have a header and a footer, so could a section, and so could an article, all depending on which tag contains them (please check that out though).
Basically how do you tell google a container full of information is an individual entry when you put its individual elements in other divs, then wrapping it all in more tangled boxes? put it in an article. How do you tell google that a group of articles are related? put them in a section with a suitable heading.
The use of h1-h6 tags has implied importance often for screen readers, SEO, and visually. How you use these probably depends on your content. I suppose it is entirely possible that your page may only need one level of heading tag, but more likely if you have more content you have a page title in h1, section headings in h2, and article headings in h3... It's common sense already. Heading something with h5 that contains items with h1's is probably a bad move, and possibly a bad attempt to manipulate search data, so reduce them as they are nested.
div tags are still valid, these other tags exist so that you can enhance your code with extra tools providing context both for machines and people. xhtml is working fine, but it's easy to see standardization and even code reduction coming out of html5 examples around the web, and that has got to help give us more control over what the robots take from our websites.
Comment: 30
Its implementation is probably waiting for wide adoption of the ouline algorithm and old site to die out.
There's also discussion about main content algorithm, I think it is based on that html file is like any other document with title and contents. But, having that its media is online, people abuse it to also feature ads and site links, so we put those ASIDE.
Comment: 31
Comment: 32
Comment: 33