Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are we not supposed to be using the <main> element anymore?

Like most of my SO questions, this one stems from my inability to find up-to-date Google results.

It's been almost 3 years since <main> was accepted into the HTML5.1 spec. It seems to make perfect semantic sense to use:

<header></header>
<main></main>
<footer></footer>

But I see a lot of semantics-powered sites (like CanIUse and CSS-Tricks) that simply ignore the element, instead using something like:

<header></header>
<div class="main-wrapper">
    <!--no ARIA role, nothing to semantically indicate "main" content-->
</div>
<footer></footer>

I feel like I've missed some conversation about how everyone needs to stop using <main> and Google's not helping me find that conversation. Was the element deemed unnecessary (i.e. clients don't really ever parse for it)?

Now it seems IE never ended up supporting it (sans polyfill), but is that why folks aren't using it? The same sites I've seen use div.main-wrapper do LOTs of things that still require polyfills for IE. Why not still use the semantic benefits of <main>, which only requires a 1 line JS shiv and a display:block?

like image 471
Phil Tune Avatar asked Sep 03 '15 18:09

Phil Tune


2 Answers

(i.e. clients don't really ever parse for it)?

All major browsers except IE have implemented the parsing/styling and semantics mapping (role=main) for the main element, Edge has implemented. 3 years is not a long time in terms of uptake for a new element (although its usage is already much higher than some other new elements added years before it). Its use is steadily growing over time (you can grep the data from http://webdevdata.org if you are so inclined).

All major screen readers support main element semantics as part of landmark navigation.

63% of screenreader users sometimes/ often/ always use landmarks/ regions (so add them, or I’ll spank you). - Bruce Lawson

like image 160
Steve Faulkner Avatar answered Sep 18 '22 12:09

Steve Faulkner


Answer: You should not avoid using the main element just because some other prominent sites/developers you run across are not using it.

There has been no conclusion among anybody anywhere to stop using main or to suggest to others that they should not be using it.

It’s not a requirement that you use it. But if you use it in a way that doesn’t cause the W3C validator to emit an error or warning, and in way you judge conveys the meaning/structure of your document as you the author intend—then go for it. That’s what it’s there for.

like image 31
2 revs Avatar answered Sep 17 '22 12:09

2 revs