Width

The width property sets the width of an element. If 'box-sizing' is set to 'content-box' (default) the total width of an element is width + padding + borders (and in terms of the space it takes up on the page + margin too). However, if the width hasn't been given a numeric or percentage value (or has been explicitly set to 'auto') it will have a value of 'auto'. Applying padding, margin and border values when width is 'auto' causes the browser to decrease the value it calculates for width. Otherwise the element would be too big for it's parent element - which is what happens if you enter a value of '100%' for width and then add margins, padding or borders.

If 'box-sizing' is set to 'border-box' padding and border values are not added to the defined width. The defined width specifies the total width. So if you set width to '100' and border-left to '20' the total width would be '100' as opposed to '120' (the padding forces the width down to '80').

Value Description
(numeric)e.g. '400' would set the width to 400 pixels. Other commonly used units include 'em' and '%'. So you could enter '50%' in the Width field.

Themeover CSS Reference

Close