<!ELEMENT (th|td) - O %body.content> <!ATTLIST (th|td) -- header or data cell -- %attrs; -- id, lang, dir and class -- axis CDATA #IMPLIED -- defaults to cell content -- axes CDATA #IMPLIED -- list of axis names -- nowrap (nowrap) #IMPLIED -- suppress word wrap -- rowspan NUMBER 1 -- number of rows spanned by -- -- cell -- colspan NUMBER 1 -- number of cols spanned by -- -- cell -- %cell.halign; -- horizontal alignment in -- -- cells -- %cell.valign; -- vertical alignment in cells -- >
TH elements are used to represent header cells, while TD elements are used to represent data cells. This allows user agents to render header and data cells distinctly, even in the absence of style sheets.
Cells can span multiple rows and columns, and may be empty. Cells spanning rows contribute to the column count on each of the spanned rows, but only appear in the markup once (in the first row spanned). The row count is determined by the number of TR elements. Any rows implied by cells spanning rows beyond this should be ignored.
If the column count for the table is greater than the number of cells for a given row (after including cells for spanned rows), the missing cells are treated as occurring on the right hand side of the table and rendered as empty cells. If the language context indicates a right to left writing order, then the missing cells should be placed on the left hand side.
It is possible to create tables with overlapping cells, for instance:
<table border> <tr><td rowspan=2>1<td>2<td>3 <tr><td rowspan=2>4 <tr><td colspan=2>5<td>6 </table>
which might look something like:
/-----------\ | 1 | 2 | 3 | | |-------| | | 4 | | |---|...|---| | 5 : | 6 | \-----------/
In this example, the cells labelled 4 and 5 overlap. In such cases, the rendering is implementation dependent.
The AXIS and AXES attributes for cells provide a means for defining concise labels for cells. When rendering to speech, these attributes may be used to provide abbreviated names for the headers relevant to each cell. Another application is when you want to be able to later process table contents to enter them into a database. These attributes are then used to give database field names. The table's class attribute should be used to let the software recognize which tables can be treated in this way.
Note: It is recommended that implementors provide support for the Netscape 1.1 WIDTH attribute for TH and TD, although this isn't part of the current specification. Document authors are advised to use the width attribute for the COL element instead.