CoderTools
Independence Software LLP
Login to CoderTools Sign-in to CoderTools

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


Name Values Description
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


Name Values Description
Width length e.g. 100px
auto
Specify the height in length units, or auto the browser will automatically size the height for you.


CoderTools TotalEdit - The Free Text Editor

A powerful editor and notepad replacement TotalEdit makes it easier to complete your file editing and software development tasks. TotalEdit is FREE for commercial and non-commercial purposes (its freeware).