Connected: An Internet Encyclopedia
4.5. The TABLE element
Up:
Connected: An Internet Encyclopedia
Up:
Requests For Comments
Up:
RFC 1942
Up:
4. A walk through the Table DTD
Prev: 4.4. Standard Units for Widths
Next: 4.6. Table Captions
4.5. The TABLE element
4.5. The TABLE element
<!ENTITY % Where "(left|center|right)">
<!ELEMENT table - - (caption?, (col*|colgroup*), thead?, tfoot?, tbody+)>
<!ATTLIST table -- table element --
%attrs; -- id, lang, dir and class --
align %Where; #IMPLIED -- table position relative to --
-- window --
width CDATA #IMPLIED -- table width relative to window --
cols NUMBER #IMPLIED -- used for immediate display mode --
border CDATA #IMPLIED -- controls frame width around --
-- table --
frame %Frame; #IMPLIED -- which parts of table frame to --
-- include --
rules %Rules; #IMPLIED -- controls rules between cells --
cellspacing CDATA #IMPLIED -- spacing between cells --
cellpadding CDATA #IMPLIED -- spacing within cells --
>
The TABLE element requires both start and end tags. Table elements
start with an optional CAPTION element, optionally followed by either
one or more COL elements, or one or more COLGROUP elements, then an
optional THEAD, an optional TFOOT, and finally one or more TBODY
elements.
- ID, CLASS, LANG and DIR
-
See earlier description of common attributes.
- ALIGN
-
Defines the horizontal position of the table relative to the
current left and right margins. ALIGN=CENTER centers the table
midway between the left and right margins. ALIGN=LEFT positions
the table at the left margin, while ALIGN=RIGHT positions the
table at the right margin. User agents may flow text around the
right handside of the table for ALIGN=LEFT, or the left handside
for ALIGN=RIGHT.
Note you can use <BR CLEAR=LEFT> after the table element if you
want to avoid text flowing along side the table when you have
specified ALIGN=LEFT, or <BR CLEAR=RIGHT> for a right aligned
table. To prevent a right aligned table flowing around something
else, use <BR CLEAR=RIGHT> before the table etc. Greater control
over textflow is possible using style sheets.
- WIDTH
-
Specifies the desired width of the table. In addition to the
standard units, the "%" sign may used to indicate that the width
specifies the percentage width of the space between the current
left and right margins, e.g. width="50%". In the absence of this
attribute, the table width can be determined by the layout
algorithm given later on.
It is recommended that the table width be increased beyond the
value indicated by the WIDTH attribute as needed to avoid any
overflow of cell contents. Such increases should try to avoid
drastic changes to relative column widths specified by the
author. To avoid the need for excessive horizontal scrolling, or
when such scrolling is impractical or undesired, it may be
appropriate to split words across lines.
- COLS
-
Specifies the number of columns for the table. If present the
user agent may render the table dynamically as data is received
from the network without waiting for the complete table to be
received. If the WIDTH attribute is missing, a default of "100%"
may be assumed for this purpose. If the COLS attribute is
absent, a prepass through the table's contents is needed to
determine the number of columns together with suitable values
for the widths of each column.
- BORDER
-
Specifies the width of the border framing the table, see
standard units.
- FRAME
-
Specifies which sides of the frame to render.
<!ENTITY % Frame
"(void|above|below|hsides|lhs|rhs|vsides|box|border)">
- VOID
-
Don't render any sides of the frame.
- ABOVE
-
The top side of the frame
- BELOW
-
The bottom side of the frame
- HSIDES
-
The top and bottom sides of the frame
- LHS
-
The left hand side of the frame
- RHS
-
The right hand side of the frame
- VSIDES
-
The left and right sides of the frame
- BOX
-
All four sides of the frame
- BORDER
-
All four sides of the frame
The value "Border" is included for backwards compatibility with
deployed browsers. If a document includes <TABLE BORDER> the
user agent will see FRAME=BORDER and BORDER=_implied_. If the
document includes <TABLE BORDER=_n_> then the user agent should
treat this as FRAME=BORDER except if _n=0_ for which FRAME=VOID
is appropriate.
Note: it would have been preferable to choose values for FRAME
consistent with the RULES attribute and the values used for
alignment. For instance: none, top, bottom, topbot, left, right,
leftright, all. Unfortunately, SGML requires enumerated
attribute values to be unique for each element, independent of
the attribute name. This causes immediate problems for "none",
"left", "right" and "all". The values for FRAME have been chosen
to avoid clashes with the RULES, ALIGN and VALIGN attributes.
This provides a measure of future proofing, as it is anticipated
that that the FRAME and RULES attributes will be added to other
table elements in future revisions to this specification. An
alternative would be to make FRAME a CDATA attribute. The
consensus of the HTML-WG was that the benefits of being able to
use SGML validation tools to check attributes based on
enumerated values outweighs the need for consistent names.
- RULES
-
Specifies where to draw rules within the table interior.
<!ENTITY % Rules "(none | groups | rows | cols | all)">
- NONE
-
Suppresses internal rulings.
- GROUPS
-
The THEAD, TFOOT and TBODY elements divide the table into
groups of rows, while COLGROUP elements divide the table
into groups of columns. This choice places a horizontal rule
between each row group and a vertical rule between each
column group. Note that every table has at least one row and
one column group.
- ROWS
-
As RULES=GROUPS plus horizontal rules between all rows. User
agents may choose to use a heavier rule between groups of
rows and columns for emphasis.
- COLS
-
As RULES=GROUPS plus vertical rules between all columns.
User agents may choose to use a heavier rule between groups
of rows and columns for emphasis.
- ALL
-
Place rules between all rows and all columns. User agents
may choose to use a heavier rule between groups of rows and
columns for emphasis.
If a document includes <TABLE BORDER> or <TABLE BORDER=_n_> then
the default for the table element is RULES=ALL, except if _n=0_
for which RULES=NONE is appropriate.
- CELLSPACING
-
This attribute is intended for backwards compatibility with
deployed user agents. It specifies the space between the table
frame and the first or last cell border for each row or column,
and between other cells in the table. See standard units.
Greater control will be possible using style sheet languages.
- CELLPADDING
-
This attribute is intended for backwards compatibility with
deployed user agents. It specifies the amount of space between
the border of the cell and its contents both above/below, and
left//right. See standard units. Greater control will be
possible using style sheet languages.
If a fixed width is set for the table or column, the CELLSPACING and
CELLPADDING may demand more space than assigned. Current practice is
for the latter to take precedence over WIDTH attributes when a
conflict occurs, although this isn't required by this specification.
Next: 4.6. Table Captions
Connected: An Internet Encyclopedia
4.5. The TABLE element