At the moment, HTML5 standards create titles/headings automatically from the first heading it finds in the article/section/nav etc. The problem I have is seeing why <caption> shouldn’t be treated the same way as headings (for the purpose of the outline).
Take the below code for example. It’s what you have to resort to in order to have a titled section in the document outline:
<table>
<caption>Results from zombie duck experiment</caption>
<h2 style="display: none;">Results from zombie duck experiment</h2>
<tr>
<td>FAILURE</td>
<td>FAILURE</td>
</tr>
</table>
(Which produces this outline: http://gsnedders.html5.org/outliner/process.py?url=http%3A%2F%2Froncya.com%2Ftransfer%2FHTML5CaptionDocumentOutline2.htm)
I understand why that works; HTMLDoctor go so far as to say that it is the recommended way of doing things:
For accessibility reasons, we recommend each sectioning element have a heading, even
<aside>and<nav>. If you don’t want these headings to be visible, you can always hide them with CSS. —http://html5doctor.com/outlines/
Sure, but why not this?:
<table>
<caption>Results from zombie duck experiment</caption>
<tr>
<td>FAILURE</td>
<td>FAILURE</td>
</tr>
</table>
(Which produces this failed outline: http://gsnedders.html5.org/outliner/process.py?url=http%3A%2F%2Froncya.com%2Ftransfer%2FHTML5CaptionDocumentOutline1.htm)
I’m assuming that the W3C made a conscious decision and the only ideas I have are that:
- Tables, while they do have an ending tag, aren’t really used as ‘wrappers’ like div, span, article, section, nav and similar. So in that sense, they don’t define a ‘surrounded section’
- Headings are headings and captions are not headings (…which doesn’t answer much)
- Typical captions don’t make for suitable titles (I disagree with this)
As for number 3, I think that a typical caption would still be useful as a title in a document outline. Regardless of wether they’re on top of the table or below. Heck, I can’t even see why it would be worse than nothing. Take these possible captions for example- I reckon they would all be appropriate document outline section titles:
- Results from zombie duck experiment
- Figure 3b
- Windows 8 Region Pricing
- Which brand contains what?
- Cheat codes
- Colours
- Abraham Lincoln’s attire at different periods of history
It would sure make sense to me.
In HTML5, it’s intended that the caption contains not just a brief title, but descriptive prose explaining the table. The spec provides one example of use of caption:
This would not make for a good title for the document outline.
I would suggest that you put the
<h?>inside the caption if you want it to appear in the document outline. In the example above, this would be suitable:or in your example: