CKTIS / CSS
table-layout — table width layout algorithm
The `table-layout` property selects automatic or fixed table layout. It controls whether cell content influences column widths; it does not set row heights.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, verification passed for this version of the usage example
Syntax
table-layout: auto | fixed;table-layout applies to tables, including elements with display: table or display: inline-table. Its initial value is auto; it is not inherited. With auto, the browser considers content and width constraints. CSS 2 does not mandate one exact automatic algorithm.
With fixed, column widths come first from column widths, then from first-row cell widths; remaining columns share the available space. Content in later rows does not change those widths. Borders and spacing also participate in the calculation.
For predictable behavior, give the table an explicit width. Do not rely on fixed with width: auto: CSS 2 permits a browser-dependent exception, while the CSS Tables Level 3 draft specifies automatic mode for auto and max-content. fixed alone guarantees neither equal columns nor clipped text; handle overflow separately.
In the example, width: 300px and a first-column width of 100px leave 200px for the second column. overflow: hidden clips the long text, while white-space: nowrap prevents wrapping. This result was verified for this version of the example.
Examples
<!doctype html>
<meta charset="utf-8">
<title>table-layout</title>
<style>
table {
table-layout: fixed;
width: 300px;
border-collapse: separate;
border-spacing: 0;
}
col:first-child { width: 100px; }
td {
padding: 0;
overflow: hidden;
white-space: nowrap;
}
</style>
<table aria-label="Products">
<colgroup><col><col></colgroup>
<tbody>
<tr><td>ID</td><td>Product</td></tr>
<tr><td>1</td><td>ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
</tbody>
</table>Result
Table width: 300px. Column widths: 100px and 200px. The long text is clipped inside the second column.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.