CSS Sizing
Published Aug 9, 2021Updated Sep 9, 2021
Contribute to Docs
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.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn CSS on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- In this CSS tutorial, you’ll learn how to add CSS to visually transform HTML into eye-catching sites.
- Beginner Friendly.6 hours