[html5] td and th

Jukka K. Korpela jukka.k.korpela at kolumbus.fi
Tue Apr 5 00:51:55 PDT 2011


Luis-Miguel Rodríguez Rojas wrote:

> Why does the <th> element [...] have a Phrasing content model [...]
> whilst the <td>element [...] have a Flow content model [...]?

I had not noticed this change (from HTML 4.01 and its predecessors), but I 
think it is rather natural on semantic grounds. A table header cell contains 
header information for a column or a row, and header-like elements are 
generally just text and text-level markup (cf. to <h1> and <caption>, for 
example). A data cell may contain just about anything, such as text 
paragraphs, lists, or inner tables, even in a table that represents tabular 
data (which is a much wider concept than "numeric table").

Thus, the stricter content model probably helps to detect accidental use of 
<th> where <td> should be used, as well as markup based on misunderstanding 
of HTML semantics - assuming, of course, that the author uses suitable 
software to check the markup.

The only potential objection that I can imagine for now is that a table 
header might reasonably act as a tool for sorting or otherwise modifying the 
data in the table or its rendering. Typically this means just making the 
header content a link so that e.g. clicking on a particular column header 
sorts the table so that the column appears in alphabetic or numeric order, 
and this can be arranged using just text-level markup there (whether we use 
client-side, server-side, or combined implementation of the operation). But 
would it be possible that someone reasonably wanted to use a _form_ in a 
table header cell? I mean a form where the user selects a sorting criterion, 
for example. Perhaps in the simplest case, the form might consist of a 
<select> element and (at least when scripting is disabled) a submit button - 
but to make it work robustly, with a server-side backup, it would need to be 
a <form>.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/ 




More information about the Help mailing list