CSS table-layout Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The table-layout property sets the algorithm used to size <table> columns. It applies to table and inline-table boxes (including elements with those display values).

The initial value is auto: columns grow to fit content. With fixed, widths come from the table’s width, <col> widths, or the first row — later cells do not rewrite column sizes. fixed needs an explicit table width; otherwise the browser keeps using auto layout.

Baseline · Widely available.

Not deprecated. Standard-track CSS for table and inline-table elements. Not a runtime API.

CSS Syntax

syntax.css
table-layout: auto | fixed | initial | inherit;

Property Values

ValueDescriptionTry it
autoDefault. Column widths follow cell contentTry it
fixedWidths from table/column/first-row rules. Needs a table widthTry it
initialResets to autoTry it
inheritTakes the value from the parent elementTry it

How to Use table-layout

Set the algorithm on the table, then give fixed layout a real width.

  1. Start with a real <table> (or an element with display: table).
  2. Choose table-layout: auto or fixed on that table.
  3. For fixed, set an explicit width (for example 100% or 240px).
  4. Optionally set column widths on <col> or the first row. Handle long text with overflow, white-space, and text-overflow.
PieceRequired?Role
Table boxYesProperty applies to table / inline-table
KeywordYesChooses auto or fixed algorithm
Table widthFor fixedWithout it, fixed falls back to auto
Column / first-row widthsOptionalGuide fixed column sizes

Live Preview

Same table and width. Switch between auto and fixed and watch how the long cell affects columns.

Table width stays 240px. Only the layout algorithm changes.

Table
Sample names
FirstLast
EdWood
WilliamShakespeare

table-layout: fixed

CSS Examples

Each snippet focuses on table-layout. Borders and width exist only so the algorithm is visible. Use Try It Yourself for a live editor.

Example 1 — Content-Based Columns

Let cell content decide how wide each column becomes.

CSS
<style>
  table {
    table-layout: auto;
    width: 240px;
    border-collapse: collapse;
  }
  th, td {
    border: 1px solid #cbd5e1;
    padding: 6px;
  }
</style>

<table>
  <tr><th>First</th><th>Last</th></tr>
  <tr><td>Ed</td><td>Wood</td></tr>
  <tr><td>William</td><td>Shakespeare</td></tr>
</table>
Try It Yourself

How It Works

  1. Use the default algorithm. table-layout: auto sizes columns from content.
  2. Scan cell content. Longer text (like “Shakespeare”) can widen its column.
  3. Width is a max guide. The table still respects content when auto is active.
  4. Good for small tables. Simple and flexible; can be slower on very large tables.

Example 2 — Fixed Column Algorithm

Lock horizontal layout from the table width and first-row rules.

CSS
<style>
  table {
    table-layout: fixed;
    width: 240px;
    border-collapse: collapse;
  }
  th, td {
    border: 1px solid #cbd5e1;
    padding: 6px;
  }
</style>

<table>
  <tr><th>First</th><th>Last</th></tr>
  <tr><td>Ed</td><td>Wood</td></tr>
  <tr><td>William</td><td>Shakespeare</td></tr>
</table>
Try It Yourself

How It Works

  1. Set an explicit width. width: 240px makes fixed take effect.
  2. Switch to fixed. Column widths come from the table width and first-row cells.
  3. Ignore later content for sizing. “Shakespeare” does not rewrite the column width.
  4. Render sooner. Layout can finish after the first row is known — useful for large tables.

Example 3 — Fixed with Ellipsis

Keep a narrow fixed table and clip long words cleanly.

CSS
<style>
  table {
    table-layout: fixed;
    width: 160px;
    border-collapse: collapse;
  }
  td {
    border: 1px solid #cbd5e1;
    padding: 6px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
</style>

<table>
  <tr><td>Ed</td><td>Wood</td></tr>
  <tr><td>William</td><td>Shakespeare</td></tr>
</table>
Try It Yourself

How It Works

  1. Keep fixed + width. Columns stay narrow even when words are long.
  2. Stop wrapping. white-space: nowrap keeps each cell on one line.
  3. Clip overflow. overflow: hidden cuts anything past the cell edge.
  4. Show an ellipsis. text-overflow: ellipsis marks clipped text with …

Edge Cases & Pitfalls

If fixed layout looks identical to auto, check these first.

width

fixed needs an explicit table width

If width is auto or missing, browsers use the automatic algorithm and ignore fixed.

first row

First row (or col) sets fixed widths

Later rows do not change column sizes under fixed layout. Put width hints on <col> or the first row of cells.

overflow

Long content can spill

Fixed columns will not grow for long words. Use overflow, white-space, and text-overflow when clipping is intended.

target

Only table boxes

Applies to table / inline-table. A normal div ignores it unless you set a table display type.

a11y

Keep real table markup

Use semantic <table>, headers, and captions. Layout algorithms do not replace accessible table structure.

Browser Support

table-layout is a browser CSS property for HTML table column algorithms. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

table-layout

auto and fixed are widely supported across modern browsers and Internet Explorer.

100% Core keyword support
Google Chrome All versions
Full support
Mozilla Firefox All versions
Full support
Apple Safari All versions
Full support
Microsoft Edge All versions
Full support
Opera All versions
Full support
Samsung Internet All versions
Full support
Internet Explorer All versions
Full support
table-layout Widely supported

Bottom line: Safe to teach and ship for auto and fixed. Remember: fixed needs a table width. It is not a runtime API.

Key Takeaways

  • Role: choose auto (content) or fixed (width/first-row) column sizing.
  • Initial value: auto. Columns follow cell content.
  • fixed rule: set an explicit table width or fixed behaves like auto.
  • Overflow: long fixed cells may need ellipsis or wrapping controls.

One line: use auto when content should drive columns; use fixed with a real table width when you want predictable, faster layout.

Frequently Asked Questions

It chooses the algorithm used to size table columns: auto (content-based) or fixed (width-based from the table, columns, or first row).
The initial value is auto. Columns grow to fit cell content.
fixed needs an explicit table width. If width is auto or omitted, browsers fall back to the automatic layout algorithm.
Use fixed for predictable column widths, faster rendering of large tables, or when you want later rows not to change column sizes.
Content can overflow the cell. Pair fixed with overflow, white-space, and text-overflow when you want clipping or an ellipsis.
It is Baseline Widely available across modern browsers and Internet Explorer. It is a browser CSS property, not a Node.js feature.

Next: text-align

Learn how to align inline content horizontally inside a block or table cell.

text-align tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful