I don’t know if you’re like me, but sometimes I can’t help but feel that my good buddy XHTML is flawed. That is, take a look at the following example:
<p> <ol> <li></li> </ol> <p>
Well, this is wrong structurally. Why, because both <p> and <ol> are block elements, which means they can’t be inside each other. But the truth is, this concept is fundamentally flawed because making a list part of a paragraph makes sense, both visually and structurally, in my opinion at least. The point is, my list may be talking about something located in the paragraph, rather than about another subject (as the start of a new block/paragraph usually implies). As well, this can be observed with blockquotes, which are often visually part of a paragraph but are structurally separated from it because they are block elements.
My take on this is certainly not to modify the way XHTML is made by removing the block vs inline concept. This concept is really awesome, don’t misunderstand me. Rather, the block elements should be able to reside inside other block elements, as this is structurally ok (see divs or lists being nestable). Even paragraphs could be nested inside other paragraphs, although this is a bit pushed, yet not so farfetched, here’s why.
In XHTML 2.0, block elements can now be placed in paragraphs. See, I wasn’t so wrong to think this was a great idea. However nestable everything becomes though, I don’t think they got it quite right in structural logic, yet. Paragraphs still can’t be nested in each other. Here’s the draft’s current take:
<section>
<h>Heading</h>
<section>
<h>Sub-Heading 1</h>
<p>Paragraph</p>
</section>
<section>
<h>Sub-Heading 2</h>
<p>Paragraph</p>
</section>
</section>
So, rather than explaining everything that is wrong with this example, here is what I think it should look like:
<section>Heading <section>Sub-Heading 1 <section>Paragraph</section> </section> <section>Sub-Heading 2 <section>Paragraph</section> </section> </section>
As you can see, my approach is more structural, reduces the amount of tags needed and arguably provides more flexibility than XHTML 2.0’s current draft. Everything is nestable in the same way current lists are nested, which makes a lot of sense. Giving the look to the text in an efficient way is then simply a matter of applying depth-based (hierachically talking) CSS properties.
Tell me what you think.