HTML and CSS Reference
In-Depth Information
Figure 5-25
Increased padding and spacing within the Web table
Setting Table Widths and Heights in HTML
You can use HTML to set the overall width and height of a table and of the individual
cells within the table. By default, the width of a table ranges from the minimum neces-
sary to display all the cell contents without line wrapping, up to the width of the con-
tainer element. To set the width of a table to a specifi c value, you add the width attribute
<table width=” value ”> ... </table>
to the table element, where value is the width either in pixels or as a percentage of the
width of the containing element. If the containing element is the page itself, you can set
the table to fi ll the entire page width by specifying a width value of 100%. You still can
never reduce a table to a width smaller than is required to display the content or larger
than the width of its container. For example, if table content requires a width of 450 pix-
els, then browsers will ignore any width attribute that attempts to set a smaller table size.
Many browsers also support the height attribute, which has the syntax
<table height=” value ”> ... </table>
where value is the height of the table either in pixels or as a percentage of the height
of the containing element. Even though the height attribute is widely supported for the
table element, it is not part of the specifi cations for any version of HTML or XHTML.
Like the width attribute, the height attribute indicates only the minimum height of the
table. If table content cannot fi t into the specifi ed height, the table height increases to
accommodate the content.
You also can set the widths of individual columns by applying the width attribute to
either an individual column or a column group. For example, the HTML code
<colgroup width=”100” span=”7”>
Search WWH ::

Custom Search