Measurement fundamentals

Height and width are the measurements used most frequently. To set these measurements, use the height and width properties.

Inline elements gain layout when the height or width is set. Inline elements with layout expose the same layout properties, such as border, margin, and padding, as block elements.

When setting or retrieving the measurement and location values of an element, you can use different length units to achieve a particular style. Using length units consistently simplifies measurement and location values. The mixing of length units requires you to determine the value of an absolute length unit programmatically, based on a relative unit for every system. For example, you would have to convert inches to pixels on every computer that renders your document.

In strict mode, layout properties contribute to the visual attributes of an element but do not directly reflect the dimensions of the content box. Since margin, border, and padding no longer share a part in the overall size of a content box, the contents of an element can be specifically expressed by defining its height, width, or both. This is dramatically different from the space assessment in quirks mode, where border and padding must be subtracted from the content box in order to derive its width.

Community Additions

ADD
Show: