Home CSS Properties table-layout CSS table-layout Property Definition
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.
Syntax
CSS Syntax table-layout: auto | fixed | initial | inherit ;
Values
Property Values Value Description Try it autoDefault. Column widths follow cell content Try itfixedWidths from table/column/first-row rules. Needs a table width Try itinitialResets to auto Try itinheritTakes the value from the parent element Try it
Approach
How to Use table-layout Set the algorithm on the table, then give fixed layout a real width.
Start with a real <table> (or an element with display: table). Choose table-layout: auto or fixed on that table. For fixed, set an explicit width (for example 100% or 240px). Optionally set column widths on <col> or the first row. Handle long text with overflow , white-space , and text-overflow . Piece Required? Role Table box Yes Property applies to table / inline-table Keyword Yes Chooses auto or fixed algorithm Table width For fixed Without it, fixed falls back to auto Column / first-row widths Optional Guide fixed column sizes
Try it
Live Preview Same table and width. Switch between auto and fixed and watch how the long cell affects columns.
Code
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.
1. Auto 2. Fixed 3. Fixed + ellipsis Example 1 — Content-Based Columns Let cell content decide how wide each column becomes.
<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> First Last Ed Wood William Shakespeare
How It Works Use the default algorithm. table-layout: auto sizes columns from content.Scan cell content. Longer text (like “Shakespeare”) can widen its column.Width is a max guide. The table still respects content when auto is active.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.
<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> First Last Ed Wood William Shakespeare
How It Works Set an explicit width. width: 240px makes fixed take effect.Switch to fixed. Column widths come from the table width and first-row cells.Ignore later content for sizing. “Shakespeare” does not rewrite the column width.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.
<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> How It Works Keep fixed + width. Columns stay narrow even when words are long.Stop wrapping. white-space: nowrap keeps each cell on one line.Clip overflow. overflow: hidden cuts anything past the cell edge.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 widthIf 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.
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.
Compatibility
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.
Remember
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 What does the CSS table-layout property do? It chooses the algorithm used to size table columns: auto (content-based) or fixed (width-based from the table, columns, or first row).
What is the default value of table-layout? The initial value is auto. Columns grow to fit cell content.
Why does table-layout: fixed seem to do nothing? fixed needs an explicit table width. If width is auto or omitted, browsers fall back to the automatic layout algorithm.
When should I use fixed? Use fixed for predictable column widths, faster rendering of large tables, or when you want later rows not to change column sizes.
What happens to long text in a fixed table? Content can overflow the cell. Pair fixed with overflow, white-space, and text-overflow when you want clipping or an ellipsis.
Which browsers support table-layout? 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 Developer, cloud engineer, and technical writer
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
Helpful Share Copy link Suggestion