CSS table-layout property

CSS Table table-layout Property

Description

The table-layout property determines the layout method used when rendering a table.

Possible Values

  • auto − The table should be laid out according to an automatic layout algorithm. The browser will do this automatically.
  • fixed − The table should be laid out according to the provided fixed table layout method.


Applies to

Any element with the display property set to table or inline-table.

DOM Syntax

object.style.tableLayout = "fixed"; 

Example

Note – Many browsers do not support this property, so do not rely on it.

<html> 
<head> 
<style type = "text/css"> 
table.auto { 
table-layout: auto 
} 
table.fixed { 
table-layout: fixed 
} 
</style> 
</head> 

<body> 
<table class = "auto" border = "1" width = "100%"> 
<tr> 
<td width = "20%">1000000000000000000000000000</td> 
<td width = "40%">10000000</td> 
<td width = "40%">100</td> 
</tr> 
</table> 
<br /> 

<table class = "fixed" border = "1" width = "100%"> 
<tr> 
<td width = "20%">1000000000000000000000000000</td> 
<td width = "40%">10000000</td>
<td width = "40%">100</td>
</tr>
</table>

</body>
</html>

This will generate the following output −

CSS Table table-layout Property

Leave a Reply

Your email address will not be published. Required fields are marked *