Let’s say aside
element includes “Oh, by the way …” content such as reading suggestions, advertisements, or cross sells.
- Is it semantically okay to have
aside
outside ofmain
? - If yes, does it have any advantage over accessibility if I keep
aside
outside ofmain
, such as “skip to main content” command? - Last but not the least, I would like to know if there is any SEO impact if I include
aside
tag outside or inside ofmain
.
2
Answers
If your
<aside>
is directly related to the content in you<main>
then I would leave it in the<main>
. Now, that being said…<aside>
outside a<main>
(as in, it is valid, but your content might warrant otherwise).<aside>
outside a<main>
has no harm nor benefit for accessibility. As long as you follow good structure and valid mark-up, you should be fine.<aside>
s outside<main>
on my site, and had<aside>
s inside<main>
as well, and I have seen no difference in my ranking. Given that search engines are generally opaque about specific bits like this, I would consider some A/B testing if you are concerned.Related materials from HTML5 Doctor, which is written by one of the HTML5 spec editors:
In HTML5 it’s only defined that
aside
is “related to the content around theaside
element”.In HTML 5.1 (CR) the definition became more specific, as it now says that
aside
is “related to the content of the parenting sectioning content“.Following the newer definition, the
aside
element should be inside of the section element to which it is related. Themain
element is not a sectioning element (elements likearticle
,section
,body
,figure
etc. are). You can of course still placeaside
inmain
, but it will be related to the nearest sectioning element parent ofmain
.That means there is no semantic difference (for
aside
) in these two examples:Example that shows a few different cases: