CSS - Specifying Element Size using Height and Width
Description
Height and Width allow sizing of block level elements (e.g. div, h, p, table) and images.
height: length;
width: length;
or
width: %;
Examples for Height and Width
test text test text test text test text
<style>
#test { height:100px; width: 50%; border: 1px solid black; }
</style>
<div id="test">test text test text test text test text</div>
test text test text test text test text
<style>
#test2 { height: 55px; width: 25%; border: 1px solid black; }
</style>
<p id="test2">test text test text test text test text</p>
| test text test text test text test text |
<style>
#test3 { width: 100px; border: 1px solid black; }
</style>
<table id="test3">
<tr>
<td>test text test text test text test text</td>
</tr>
</table>
Values for Width
| Width |
length e.g. 100px percentage e.g. 50% auto |
Specify the width in length units, as a percentage relative to the parent element, or auto the browser will automatically size the width for you. |
Values for Height
| Width |
length e.g. 100px auto |
Specify the height in length units, or auto the browser will automatically size the height for you. |