[whatwg] image captions
Michel Fortin
michel.fortin at michelf.com
Wed May 3 06:19:12 PDT 2006
I wrote previously:
> Well, I'm all for using <caption> -- it obviously is the most
> logical choice -- but, as stated in my first reply, the caption
> element is completely ignored by today's HTML parsers when outside
> the context of a table. This makes captions impossible to style or
> use within the DOM. That's why I'm suggesting an alternative that
> doesn't involve the caption element.
I'd like to revise what I said.
I just found out that at least one important HTML parser (Gecko)
doesn't create the right DOM tree out of something as simple as this:
<section>
<p>Some paragraph</p>
</section>
The tree will be as if you wrote this:
<section>
</section><p>Some paragraph</p>
Why? Because unknown elements are considered inline and won't accept
any block element within. This problem applies to <nav>, <header>,
<footer>, and <aside> too (and maybe others).
The point I want to make is that because simple elements like section
aren't really backward-compatible, there is probably no point in
requiring that from image captions either. Hence it could be
acceptable to allow the following markup even if current HTML parsers
are ignoring caption:
<figure>
<caption>Some image</caption>
<img src="...">
</figure>
So here is what I'm proposing:
- - -
The figure element
Block-level element, and structured inline-level element.
Contexts in which this element may be used:
Where block-level elements are expected.
Where structured inline-level elements are allowed.
Content model:
Zero or one caption element followed by inline-level content.
The figure element contains an illustration of something related to
the content surrounding it, but which can be considered separate from
that content.
- - -
I've chosen an inline-level content model because it allows not only
img, but also structured inline-level elements like pre. I'm not so
sure about that choice however.
Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/
More information about the whatwg
mailing list