Re: Tabular environment in HTML

Dave_Raggett (dsr@hplb.hpl.hp.com)
Wed, 31 Mar 93 13:05:28 BST


> Tabular work is, accordingto the experts, a can of worms.
> However, it is important. It is definitely not in HTML,
> but a good discussion is definitively in order.
> Tables in practice need all kinds of things
> (joined cells, break lines, etc) A lot of work has been done,
> it needs to be brought together and written up.

> Pointers, anyone?

> Tim

I have looked at Latex, tbl and Microsoft Word, and come up with a
rich yet easy scheme for augmenting HTML. Please look through
and voice your comments!

tbl is simple except when you want multi-line text which gets tedious
as you are forced to specify the line breaks explicitly. This can be
circumvented with a simple extension. The style of tbl leads to lots of
tabs for padding over empty cells. This comes from not being able to
say that a given cell should be further subdivided. It has a nice
feature for aligning numeric values, missing from Latex.

Latex's tablular environments are ok, but get messy for fields extending
across multiple columns.

Microsoft Word allows you to first specify the number of rows and columns
and then alter them, e.g. merging or splitting adjacent cells.

Here is my suggestion for a general scheme for specifying tables
which uses just three tags and IMHO is simpler than the above:

The following example from Lamport's Latex manual should make all this clear:

-------------------------------------------------
| CG&A Hoofed Stock |
|===============================================|
| || Price | |
| ||-------------| |
| Year || low | high | Comments |
|-----------------------------------------------|
| 1971 || 97-245 | Bad year for farmers |
| || | in the west. |
|-----------------------------------------------|
| 72 || 245-245 | Light trading due to a |
| || | bad winter. |
|-----------------------------------------------|
| 73 || 245-2001 | No gnus was very good |
| || | gnus this year. |
-------------------------------------------------

<table>
<line>
<row cols="c">
CG&A Hoofed Stock
<line>
<line>
<row cols="|cb||c|cb|">
Year <t>
<table>
<row cols="c">
Price
<line>
<row cols="r|l">
low <t> high
</table>
Comments
<row cols="nnl20">
1971 <t> 97-245 <t> Bad year for farmers in the west. <t>
72 <t> 245-245 <t> Light trading due to a heavy winter.
73 <t> 245-2001 <t> No gnus was very good gnus this year.
</table>

Tables are specified by the <table> ... </table> tag.

You specify a format for the current row. This continues until a new
specification is given:

<row cols=FORMAT> where the FORMAT is a string formed from:

l left aligned column
r right aligned column
c centered column
n numeric aligned column (on units or decimal point)

t align this cells contents at the top of the row
b align this cells contents at the bottom of the row

| a vertical line extending the height of this row only
this is repeated for mutiple lines

The vertical alignment is an optional suffix following l,r,c,n.
An optional width can be given as an integer following l, r, c
(after t or b if present) to indicate the desired width of the column
in characters (av.char width), e.g. "lt40"

Numerically aligned fields will be nominally centered, but adjusted so
that the units digits line up (or the decimal point). You can also
specify more that one number, e.g. nnn-nnn, in which case the browser
may be able to line up the "-" chars, or failing that to simply centering
the text. (Should we make "-" an optional format character, e.g. "n-n" ?)

The text for each cell is separated by a tag e.g. <t> rather than the
tab character as used by tbl.

The <line> tag ends the current row and draws a line extending across the full
extent of this table. Any missing cell values are padded with blanks.

You can nest <table> tags to split a given cell into smaller ones. The width
and height of the nested table then effects the size of the row and column
of the parent table, into which it is inserted.

All rows in a given table have the same width. The width of each cell is
determined by the cell containing the largest value for the corresponding
row and column.

It may be advisable to require all <row> tags in a table to specify the
same number of columns. In this case you then need an "s" format character
to indicate a spanned column, i.e. merged with the preceding one.

Dave Raggett

HPLabs, Bristol, UK

+44 272 228046
dsr@hplb.hpl.hp.com