HTML and ARIA by extension defines 6 heading levels. Although <div role="heading" level="7">
is technically correct, it isn't universally recognized as being an heading of level 7 by all screen readers and other assistive tools.
Jaws, for example, consider that any element with an aria-level attribute with a value outside 1-6 is an heading of level 2. Jaws' interpretation isn't against ARIA specification.
For this reason, I recommand to not use aria-level for an heading of level 7 or more.
IF you really, really, really need headings level 7 and more, just use <p>
or <div>
without any indication, so to not disturb screen readers and other assistive tools which don't support headings beyond level 6.
However, before taking this simple solution for granted, please ask yourself:
Do you really need to go that deep ?
You should ask yourself the question, because in fact, probably you don't need to.
Many people have difficulties understanding long texts and complicated structures. A normal well structured text with a reasonable length shouldn't need to use more than 3 levels.
A technical specification, an user manual or a research paper might need 4, or maybe 5 given its complexity, deepness and length. IN principle, 6 level should thus be more than sufficient to build a correct, meaningful and understandable structure.
If you need more levels, probably that whether you skip levels for no reason, or your text isn't well thought.
Can't you organize it differently ? Maybe split it in different parts ?
You are talking about <section>
and <article>
, but do they really all delimit sections or articles ?
Otherwise said, do all of them really have a sectionning role within the whole document, semantically speaking ? I doubt about it. I'm pretty sure that some of them only have a visual separation role only, in which case you should replace them by <div>
.
Look at the following question, hwere I gave a similar answer:
Is h6 aria-level="7" a reliable way to create a h7 element?