The CSS reference

"height" - css property (v. css 1)

  • This property specifies the content height of boxes generated by block-level, inline-block and replaced elements.
  • Replaced element is content which is outside the scope of the CSS formatting model, such as an image, embedded document, or applet.
  • This property does not apply to non-replaced inline-level elements.
  • Initial value: auto
  • The property is not inherited
  • HTML usage: All elements but non-replaced inline elements, table columns, and column groups
  • Browsers that support the height - property :
    Internet Explorer Mozilla Firefox Opera Google Chrome Apple Safari

How width, height, margin, border and padding properties relates to each other:


Possible height values:

height value Comments CSS
length With this you specify a positive value followed with a unit identifier (it cannot be negative). 1
percentage With this you specify a value with a percentage. It refer to height of containing block. If the height of the containing block is not specified explicitly, the value is interpreted like 'auto'. 2
auto The outcome of this property value is much dependant on the related containing block type, replaced or none-replaced elements and the browser. For details, please study computing widths and margins for behavior. 1
inherit Will inherit the value from parent specification. This property value is new with CSS 2. 2

Possible unit identifier:

unit identifier Comments CSS
em The relative unit 'em' is relative to the font size of the element itself. 1
ex The relative unit 'ex' is relative to the font size of the element itself. 1
px Pixels, relative to the viewing device 1
in inches -> 1 inch is equal to 2.54 centimeters. 1
cm centimeters. 1
mm millimeters. 1
pt points -> the points used by CSS2 are equal to 1/72th of an inch. 1
pc picas -> 1 pica is equal to 12 points. 1

Javascript access:

// To SET values ([o] is the target object)
[o].style.height="height value"
// To GET values you must first get the computed style object
// To get that object in IE or Opera:
var cStyle=[o].currentStyle;
// To get that object in Firefox, Chrome or Safari (w3c-type):
var cStyle=window.getComputedStyle([o],null)
// To GET the property value:
var value=cStyle.height;
// IE and Opera will return a value in units as used with a Set.
// Firefox will return a calculated float value in pixel (px).
// Chrome or Safari will return a calculated int value in pixel (px).
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.