[whatwg] All (new) sorts of figures

Michel Fortin michel.fortin at michelf.com
Mon Jul 16 18:18:39 PDT 2007

Since I'm not convinced that the current content model for <figure>  
is adequate [1], I decided to dig more examples where figures in HTML  
pages would be hard to fit with the current model. Here are the results.

My previous in-depth list of use cases for figures [2] was mostly  
concentrating on examples I could find by searching for "Figure  
1" (and other numbers too), and by looking at news site for image  
captions. This one is less methodic: in the last few weeks when I  
found something for which I feel the figure markup should apply to  
(because other alternatives aren't as good) but couldn't due to  
current content-model restrictions, I noted it and tried to find  
similar examples with various searches for documents of the same kind.

  [1]: http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2006- 
  [2]: http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2006-June/ 

Figures with textual content

Many labeled code from Apple documentation (search for "Listing" in  
the pages)

Many labeled code from MSDN (search for "Listing" in the pages)

Many labeled code samples (most labeled as a "Listing")

Figure 4.1
This is a code sample

Table 4.1(i)
This one is called a table (and is laid out in a table), but I'm a  
little puzzled as to why it wasn't called a figure. It's pseudo-code.

Figure 4.1
This one is an image of some C code. While it's presented as an  
image, it'd be much better (more accessible and easier to style) if  
it was in textual form.

Many figures on that page simply contain styled text as images.

Figure of a Textual Terminal Display (the whole document is the figure)

Figure 1a & 3a
Generated poems.

Figure 2

Many figure about formatting plain text documents

Many CSS code sample figures.

Figures 1, 4, and 5

Listing 1 to 4

I suggest for these cases that we allow <pre> as a child of figure,  
as in:

       <pre><code>while (1) continue;</code></pre>
       <legend>Silly code</legend>

<pre> could be limiting in some of these cases though. For instance,  
some pseudo-code examples and illustrations of generated poems in  
those cases above aren't formatted with <pre>. Here is another kind  
of figure that wouldn't work with <pre>:

Figure 1, 2, 3, and 4 are dictionary entries.

Multi-Image Examples

These examples feature figures containing many subfigures in separate  
images (often labeled a, b, c...). I have not included figures with  
multiple subfigures contained in one image file because these can  
already be expressed within the limitations of the current figure  

Figure 4.4 and 4.1

Figure 2

Figure 16, 19, 20, 21, 22, 23, 24, 28, and 29

Figure 28

Figure 14

Figure 12, 13, and 14

Figure 8, 9, 10, and 11

Figure 5

Figure 2 and 3

Figure 3

Figure 13

Figure 5, 6, and 7

Figure 5

Figure 3 and 4

Figure 6, 17, and 18

I suggest for these examples that the figure element should permitted  
to enclose more than one image. For instance:

       <img ...>
       <img ...>
       <legend>My house seen from the front and from the back</legend>

It could also be useful to allow labeling of subfigures, perhaps like  

       <figure><legend>(a)</legend> <img ...></figure>
       <figure><legend>(b)</legend> <img ...></figure>
       <legend>My house seen (a) from the front; (b) from the back</ 

A few other cases

The "Browser Rendering" figure on that page contains the browser  
rendering of elements done by placing the actual markup in the  
figure. Note: actually, it use a table to place the rendering, but  
the table seems to have been used mostly to show things in two  
distinct columns.

Browser rendering examples in these pages cover a lot of cases for  
HTML markup. Allowing any block-level content in figures is probably  
the only way to make the figure markup usable for this case.

Here are other similar cases:

This page contains an example of a layout table as a figure:

In the above, the figure caption is attached to the table itself, but  
since the whole table is the illustration I think it'd be better to  
have a figure element contain the table, like this:

       <legend>An example of a layout table and image map with no alt  

Also of interest is what looks like a textual figure just below  
(actually within an <h5> within the table caption; silly FrontPage).  
A paragraph within a figure would seem good markup to accomodate this:

       <p>"Каталог Российских Веб- 
       <legend>An example of foreign text that should be labeled  

Caption-less figures

While perhaps not all these examples are necessarily "figures"  
strictly-speaking, example rendering of HTML inserted inline in a  
document needs to be differentiated from the main text while reading.  
Here are two links, the first one use <blockquote>, the last one use  
<div class="html">:

The link above contains sample rendering of some HTML content. Here  
are some other similar examples of caption-less HTML content as a  

Ribbons as colored HTML text.

Sample paragraphs in italic.

"Sample paragraphs" section at this end.

"Will you?" poem at the end of the page.

There is nothing in HTML allowing the illustrative content to be  
separated from the main content when it is made of HTML markup  
itself. Using <blockquote> or <div class="html"> is not a very good  
as it relies on the visual rendering of these elements to be understood.

A solution for that could be to allow caption-less figures with block- 
level HTML content, as in:

     <p>Here is the result:</p>

       <p>This is a sample paragraph.</p>
       <p>Followed by another paragraph.</p>

Michel Fortin
michel.fortin at michelf.com

More information about the whatwg mailing list