Sizing

The CSS height and width properties are used to set the height and width of an element. They do not include padding, borders, or margins of the element, but instead, the height/width of the area inside the padding, border, and margin.

The height and width properties may have the following values:

  • auto (default): The browser calculates the height and width.
  • length: Defines the height/width in px, cm, etc.
  • %: Defines the height/width in percent of the containing block.
  • initial: Sets the height/width to its default value.
  • inherit: The height/width will be inherited from its parent value.

Sizing

height
Defines the height of an element's content area. The content area is the space inside the padding, border, and margin of the element.
max-height
Defines the maximum height of an element.
max-width
Defines the maximum width of an element.
min-height
Defines the minimum height of an element.
min-width
Defines the minimum width of an element.
width
Defines the width of an element's content area. The content area is the space inside the padding, border, and margin of the element.
Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn CSS on Codecademy

Edit this page on GitHub

Contributors