height

Avatar of Sara Cope
Sara Cope on (Updated on )

UGURUS offers elite coaching and mentorship for agency owners looking to grow. Start with the free Agency Accelerator today.

The height property in CSS defines specifies the content height of boxes and accepts any of the length values.

The “content” area is defined as the padding and border in addition to the height/width or size the content itself takes up.

Negative values like height: -100px are not accepted. The height property does not apply to non-replaced inline elements including table columns and column groups.

.wrap {
  height: auto;    /* auto keyword */

  height: 120px;   /* length values */
  height: 10em;
  height: 0;       /* unit-less length is OK for zero */

  height: 75%;     /* percentage value */

  height: inherit; /* inherited value from parent element */
}
Check out this Pen!

If the height of the containing block is not specified explicitly, and the element is not absolutely positioned, the value of its height computes to auto (it will be as tall as the content inside it is, or zero if there is no content). If the elements content portion requires more vertical space than available from the value assigned, the elements behavior is defined by the overflow property.

When using the keyword auto, height is calculated based on the elements content area unless explicitly specified. This means a value based on a percentage is still that of the elements content area. Similarly, if the height of the container is set to a percentage value, a child elements percentage height is still based on the content area of that child element.

Height can also be used as an animatable property.

Browser support

IEEdgeFirefoxChromeSafariOpera
AllAllAllAllAllAll
Android ChromeAndroid FirefoxAndroid BrowseriOS SafariOpera Mobile
AllAllAllAllAll
Source: caniuse