The following attributes may be set for different table elements (see their definitions).
<!-- horizontal alignment attributes for cell contents -->
<!ENTITY % cellhalign
"align (left|center|right|justify|char) #IMPLIED
char %Character; #IMPLIED -- alignment char, e.g. char=':' --
charoff %Length; #IMPLIED -- offset for alignment char --"
<!-- vertical alignment attributes for cell contents -->
<!ENTITY % cellvalign
"valign (top|middle|bottom|baseline) #IMPLIED"
Attribute definitionsalign = left|center|right|justify|char [CI]This attribute specifies the alignment of data and the justification of text in a cell. Possible values:
- left: Left-flush data/Left-justify text. This is the default value for table data.
- center: Center data/Center-justify text. This is the default value for table headers.
- right: Right-flush data/Right-justify text.
- justify: Double-justify text.
- char: Align text around a specific character. If a user agent doesn’t support character alignment, behavior in the presence of this value is unspecified.
- top: Cell data is flush with the top of the cell.
- middle: Cell data is centered vertically within the cell. This is the default value.
- bottom: Cell data is flush with the bottom of the cell.
- baseline: All cells in the same row as a cell whose valign attribute has this value should have their textual data positioned so that the first text line occurs on a baseline common to all cells in the row. This constraint does not apply to subsequent text lines in these cells.
When charoff is used to set the offset of an alignment character, the direction of offset is determined by the current text direction (set by the dir attribute). In left-to-right texts (the default), offset is from the left margin. In right-to-left texts, offset is from the right margin. User agents are not required to support this attribute.
The table in this example aligns a row of currency values along a decimal point. We set the alignment character to “.” explicitly.
<COL><COL align="char" char=".">
<TR><TH>Vegetable <TH>Cost per kilo
<TR><TD>Silver carrots <TD>$10.50
<TR><TD>Golden turnips <TD>$100.30
The formatted table may resemble the following:
| Vegetable |Cost per kilo|
|Lettuce | $1 |
|Silver carrots| $10.50|
|Golden turnips| $100.30|