CSS width property
Browser support · legacy reference
ChromeFully supports
SafariFully supports
FirefoxFully supports
Internet ExplorerFully supports
EdgeFully supports
OperaFully supports
Description
CSS width property defines physical width of an element (box). The length units might be px, em, pt, in.
Syntax
width : auto | length | percentage | min-content | max-content
Property values
autoDefault
-
auto value means the width will be changed automatically according to the content.
- Try it
width: auto; min-content
-
min-content value represents that the width of an element must be equal to or greater than the largest minimum width of some descendant item i.e. it depends upon the minimum size of child element.
In this case, the min-width of descendant element is 100px.
- Try it
width: min-content; max-content
-
max-content value means the width of an element must be equal to or greater than the largest maximum width of some descendant item i.e. it depends upon the miximum size of child element.
In this case, the max-width of descendant element is 200px.
- Try it
width: max-content;
Applicable to
It applies to all elements except non-replaced inline.