Utilizing CSS in user agents that support CSS-2.x layout engines allows for achieving full-width elements:
<style type="text/css">
.full-width {
width: 100%;
}
.table {
display: table;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
}
</style>
</head>
<body>
<ul class="table">
<li class="row">
<span class="cell full-width">
<input type="text" id="textField" class="full-width" />
</span>
<span class="cell">
<input type="button" value="foobar" />
</span>
</li>
</ul>
</body>
Successfully tested in the following browsers:
- Chromium 16.0.912.75 (Developer Build 116452 Linux), Apple WebCore 535.7
- Chromium 16.0.912.63 (Developer Build 113337 Linux), Apple WebCore 535.1
Please be aware that paddings and margins on input
elements may cause issues due to the fixed width.
However: There seems to be no compelling reason not to employ a table
element in this case (tables and CSS complement each other). Semantically, it would be appropriate (the table would be serializable), and compatibility is likely to be better than with the aforementioned CSS display
values:
<body>
<ul>
<li>
<table class="full-width"
summary="Input text field with “foobar” button">
<tr>
<td class="full-width">
<input type="text" id="textField" class="full-width" />
</td>
<td>
<input type="button" value="foobar" />
</td>
</tr>
</table>
</li>
</ul>
</body>
It is possible that using only a table
element at this location from the beginning would have been a better choice.