HTML and CSS Reference
In-Depth Information
A number of attributes can be used with table elements, although the func-
tions of many of them have been replaced by CSS properties. Here are some of
the more useful attributes that can be added to the table tag:
align Valid values are left , right , and center . let and right are
equivalent to the CSS loat property.
width he table's width, speciied as either an absolute number
of pixels or a percentage
height he table's height, speciied as either an absolute number
of pixels or a percentage
border he pixel width of the table's border and grid lines
cellspacing he number of pixels between the “walls” of adjacent cells
cellpadding he number of pixels between the “walls” of a cell and its
contents. Similar to the CSS padding property.
bgcolor he table's background color, expressed as an RGB value
he align attribute can also be added to table row and cell elements. But the
values control the text alignment property of the cell contents, not the loat-
ing properties of the element, as with the table element. his inconsistency is
due to the need for browsers to be backward-compatible with earlier versions
of HTML. In addition to the values left , right , and center , the align attribute
can have the value justify when used in table row or cell elements. he valign
attribute (vertical alignment) controls the vertical positioning of the content
within a cell. It can have the values top , bottom , or middle (the default).
Alignment speciied at the table cell level has precedence over row align-
ment, which has precedence over table body, head, or foot alignment. Con-
versely, alignment is inherited from the head/body/foot level if not speciied at
the row level, and cell alignment is inherited from the row level if not speciied
at the cell level.
he width attribute sets an initial maximum width for the table to occupy.
A browser attempts to adjust the cell sizes and word-wrap the contents of the
cells to it within this value. However, content always has a minimum width
that is determined by the number of letters in the longest word or the width of
the widest image. herefore, it is possible for a table to be wider than the value
of the width attribute's value. By contrast, the height attribute sets an initial
minimum height for the table. A browser just adds extra space above and/or
Search WWH ::

Custom Search