Table Sizing
Now that we’ve dug into the guts of table formatting and cell border appearance, we have the pieces we need to understand the sizing of tables and their internal elements. When it comes to determining table width, there are two different approaches: fixed-width layout and automatic-width layout. Heights are calculated automatically no matter what width algorithms are used.
Width
Since there are two different ways to
figure out the width of a table, it’s only logical
that there be a way to declare which should be used for a given
table. Authors can use the property
table-layout
to
select between the two kinds of table width calculation.
While the two models can have different results in laying out a specific table, the more fundamental difference between the two is that of speed. With a fixed-width table layout, the user agent can calculate the layout of the table more quickly than is possible in the automatic-width model.
Fixed layout
The main reason the fixed-layout
model is so fast is that its layout does not depend on the contents
of table cells. Instead, it’s driven by the
width
values of the table, columns, and cells
within that table.
The fixed-layout model works in the following simple steps:
Any column element whose
width
property has a value other thanauto
sets the width for that column.If a column has ...
Get Cascading Style Sheets: The Definitive Guide, Second 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.