Table and Cell Dimensions
By default, a table will render just wide enough to
contain all of its contents. You can explicitly specify the width of a
table using the width
attribute in
the table
element. The HTML
specifications provide no way to specify the height of a table,
preferring the height to be automatically determined by the table’s
contents. However, there is a nonstandard height
attribute that is well-supported for
providing minimum height for the overall table.
You can control the width and height of individual cells by using
the (you guessed it) width
and
height
attributes in the td
or th
element. Height values are considered to be minimum heights and cells
may expand downward to accommodate their contents.
Tip
The width
and height
attributes have been deprecated for
td
and th
elements, but they are not deprecated for
use in the table
element. Style
sheet properties are still the preferred method for specifying table
dimensions.
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.