The ‘table-layout’ property controls the algorithm used to lay out the table cells, rows, and columns.
Overview tableauto
object.style.tableLayout
table-layout: auto
table-layout: fixed
table-layout: inherit
This example shows table-layout ‘auto’ and 'fixed’. With 'auto’, the column stretches to encompass the largest unbreakable element. With 'fixed’, the column gets the defined width, even though the content might not fit.
<p><strong>table-layout: auto</strong></p>
<table border="1">
<tr>
<td class="first"><p>cell 1, Lorem ipsum</p></td>
<td><p>cell 2</p></td>
</tr>
<tr>
<td><p>cell 3, Suspendisse in elit lectus.</p></td>
<td><p>cell 4</p></td>
</tr>
</table>
<p><strong>table-layout: fixed</strong></p>
<table border="1" class="fixed">
<tr>
<td class="first"><p>cell 1, Lorem ipsum</p></td>
<td><p>cell 2</p></td>
</tr>
<tr>
<td><p>cell 3, Suspendisse in elit lectus.</p></td>
<td><p>cell 4</p></td>
</tr>
</table>
<p><strong>table-layout: fixed with overflow set to hidden</strong></p>
<table border="1" class="fixed2">
<tr>
<td class="first"><p>cell 1, Lorem ipsum</p></td>
<td><p>cell 2</p></td>
</tr>
<tr>
<td><p>cell 3, Suspendisse in elit lectus.</p></td>
<td><p>cell 4</p></td>
</tr>
</table>
Here’s the CSS for styling the table, above.
table {
border-color: #F00;
width: 400px;
table-layout: auto;
}
table.fixed,
table.fixed2 {
table-layout: fixed;
}
td {
border-color: #00F;
}
td.first {
width: 50px;
}
table.fixed2 td {
overflow: hidden;
}
p {
margin: 15px 0 3px 0;
}
td p {
margin: 3px;
}
Notes
Microsoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4