Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Lists, Tables and Generated Content

The table-layout property

Reference for the CSS table-layout property: how auto and fixed algorithms size table columns, when fixed is faster and more predictable, with a live comparison.

The table-layout property chooses how the browser works out the widths of table columns. With auto (the default), column widths depend on the content of every cell, so the browser must read the whole table before it can lay it out. With fixed, the widths come from the table's own width and the first row (or <col> elements), and the cell content never changes them.

CSS
table.data {
  table-layout: fixed;
  width: 100%;
}

Try it

Same table, two algorithms

In the first table the long word forces its column to be wide, even stretching the table past 300px if needed. In the second, the table stays exactly 300px and each column gets a third; the long word is clipped.

Syntax

CSS
table-layout: auto | fixed;
Initial value auto
Applies to Table elements (display: table and inline-table)
Inherited No
Animatable No
Computed value As specified

Values

Value Description
auto Automatic algorithm. Column widths are computed from the contents of all cells, so large tables render only after all rows are known.
fixed Fixed algorithm. Column widths come from <col> elements or the cells of the first row; remaining space is split evenly among columns without a width. Needs a table width other than auto to take effect.

Usage notes

  • Set a width. table-layout: fixed only triggers the fixed algorithm when the table's width is not auto. With width: auto the browser falls back to automatic layout.
  • Set widths in the first row or on <col>. Later rows cannot change a column. Give header cells (or <col>) explicit widths, such as percentages.
  • Handle overflow yourself. Content wider than its column spills over the next cell. Use overflow-wrap: anywhere, or overflow: hidden with text-overflow: ellipsis and white-space: nowrap.
  • Performance. A fixed layout lets the browser render rows as they arrive, which helps very long tables.
  • Predictable grids. It is the easy way to get equal-width columns, such as calendars.
  • Responsive tables. fixed often keeps tables inside narrow containers, but clipped data may hurt readability; consider scrolling the table in a wrapper with overflow-x: auto instead.

Browser support

Supported in all browsers.