I'm building an HTML snippet that will be dynamically included on a page. The snippet looks something like this:
<article>
<h2>Title</h2>
<p>Content</p>
</article>
The problem is that I have no way of knowing where in the document outline this snippet will be included. It may appear directly under the <h1>
, or it may be nested several levels deep under an <h4>
. In other words, my outline may look like this:
<h1>
<h2>
<h3>
<h2>
<h2>
Pretty logical. Or it may look like this:
<h1>
<h2>
<h2>
<h2>
<h2>
Not so logical. Or it may even look like this:
<h1>
<h2>
<h3>
<h2>
<h2>
<h2>
Downright weird, and I have no way of knowing or controlling it!
I'm not concerned about styling, just semantics.
I'd say the best solution would be to just use <h1>
s everywhere and let sectioning elements handle the semantics per the new HTML5 document outline, but my research has advised me against that because no client actually supports that outlining method. So what is the best solution?
Edit
A few ideas have come up in the comments that use scripting to solve the problem. These could work, but I guess I want to know if there is a sensible solution that doesn't require the added complexity of code that does things I think the browser should be doing on its own.
Hypothetically, if such scripting solutions were impossible for whatever reason, would it make sense to create a flat outline using just <h1>
s rather than create a completely wrong outline with improperly nested sub-levels?
<article role="article">
to help improve client support of the article element. – Caoutchouc