Published Aug 9, 2021Updated Sep 9, 2021
Contribute to Docs
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.
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.
- Defines the height of an element's content area. The content area is the space inside the padding, border, and margin of the element.
- Defines the maximum height of an element.
- Defines the maximum width of an element.
- Defines the minimum height of an element.
- Defines the minimum width of an element.
- Defines the width of an element's content area. The content area is the space inside the padding, border, and margin of the element.
- Anonymous contributorAnonymous contributor
- Anonymous contributor
Looking to contribute?
- 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 EngineerFront-end engineers work closely with designers to make websites beautiful, functional, and fast.
Includes 34 Courses
With Professional Certification