Column width : table cols « Tags « HTML / CSS
- HTML / CSS
- Tags
- table cols
Column width
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
<head>
<title>table-layout</title>
<style rel='stylesheet' type='text/css'>
body {
font-family: sans-serif;
}
table {
border: 1px solid black;
caption-side: bottom;
width: 200px;
table-layout: fixed;
}
th {
background: lightyellow;
}
th, td {
border: 1px solid black;
padding: 5px;
overflow: hidden;
}
col#album {
width: 200px;
background: red;
color: crimson;
}
col#released {
width: 1%;
background: pink;
}
div#control {
width: 200px;
background: crimson;
color: white;
text-align: center;
font-family: monospace;
margin-bottom: 5px;
padding: 3px 0;
}
</style>
</head>
<body>
<div id='control'>
< -- 200 pixels -- >
</div>
<table>
<caption>
My favorite records.
</caption>
<colgroup>
<col id='album' />
<col id='artist' />
<col id='released' />
</colgroup>
<thead>
<tr>
<th> album</th><th> artist</th><th> released</th>
</tr>
</thead>
<tbody>
<tr>
<td> R</td><td> AAA</td><td> 1965</td>
</tr>
<tr>
<td> B</td><td> V</td><td> 1967</td>
</tr>
<tr>
<td> M</td><td> T</td><td> 1995</td>
</tr>
</tbody>
</table>
</body>
</html>
Related examples in the same category
1. | 'cols' establishes the number of columns in a table | | |
2. | Fixed Table Sized Columns | | |
3. | Maximum-width Sized Columns | | |
4. | Minimum-width Sized Columns | | |
5. | Shrinkwrapped Table: width auto, width 20% | | |
6. | Shrinkwrapped Table: 20%, 20%, 20%, 20%, 20% | | |
7. | Equal Content-sized Columns | | |
8. | Fixed Table and Undersized Columns | | |
9. | Sized Table cannot be undersized | | |
10. | stretched table with undersized column | | |
11. | Percentage-proportioned Columns: 50%, 50% | | |
12. | Percentage-proportioned Columns: 20%, 20% | | |
13. | Percentage-proportioned Columns: 80%, 80% | | |
14. | Percentage-proportioned Columns: 80%, 20% | | |
15. | Percentage-proportioned Columns: 80%, 20%, 50% | | |
16. | Column groups | | |