concept

Fixed table layout — CSS reference

In fixed mode with an explicit width, declared column widths take precedence, then widths on the first row, then remaining columns share remaining space. Later cells do not resize these columns; their content can overflow. The example gives the first row an 80px cell width while a later cell contains 180px content.

Formal Syntax & Structure

css syntaxcss
table { width: 240px; table-layout: fixed; }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>Fixed table layout</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}body{font:16px/20px sans-serif;background:white}#a{padding:0;background:transparent;margin:10px;color:black}table{border-spacing:0}td,th{padding:0}caption{padding:0}#a{table-layout:fixed;width:240px}td{height:30px}#x{width:80px}</style><body><table id="a"><tr><td id="x">A</td><td id="y">B</td></tr><tr><td id="z"><span style="display:inline-block;width:180px">Long content</span></td><td>C</td></tr></table></body></html>
CSS Reference