Width, Height, and Box Sizing
width and height set the the width and height of an element, respectively.
<div id="height-width-example">
Hi!
</div>#height-width-example {
width: 100px;
height: 50px;
background-color: #ccc;
}Width and Height Properties
Working with Inline Elements
Settingwidth and/or height (including min-height, etc.) does not work with inline elements. Try using display: inline-block instead.width
Set's the element's width.
Possible values:
- length — (e.g.
100px) sets the width to this length - percentage — (e.g.
50%) sets the width to this percentage of the parent's width auto— sets the width automaticallymax-content— sets the width to be as large as the content needsmin-content— sets the width to be as little as possible, without causing an overflowfit-content— sets the width to be as large as the content needs, but never exceeds the parent's content area width.

height
Set the element's height.
Possible values:
- length — (e.g.
100px) sets the height to this length - percentage — (e.g.
50%) sets the height to this percentage of the parent's height auto— sets the height automatically
min-width
Ensures the element's width does not go lower than this value.
(See width for the possible values.)
min-height
Ensures the element's height does not go lower than this value.
(See height for the possible values.)
max-width
Ensures the element's width does not go higher than this value.
(See width for the possible values.)
max-height
Ensures the element's height does not go higher than this value.
(See height for the possible values.)
Inline and Block Size Properties
inline-size
Sets the size in the inline direction.
(Which direction this is depends on writing-mode. Normally refers to width when you write horizontally.)
block-size
Sets the size in the block direction.
(Which direction this is depends on writing-mode. Normally refers to height when you write horizontally.)
min-inline-size
Ensures the element's inline size does not go lower than this value.
min-block-size
Ensures the element's block size does not go lower than this value.
max-inline-size
Ensures the element's inline size does not go higher than this value.
max-block-size
Ensures the element's block size does not go higher than this value.
Box Sizing Property
box-sizing
Specifies what to be sized when setting width and height.
Possible values:
content-box— accounts only the element's content area to matchwidthandheight(default)border-box— accounts everything (including the element's border and padding area) to matchwidthandheight

References
- width (MDN) — https://developer.mozilla.org/en-US/docs/Web/CSS/width
- fit-content (MDN) — https://developer.mozilla.org/en-US/docs/Web/CSS/fit-content
- width (CSS-Tricks) — https://css-tricks.com/almanac/properties/w/width/
- height (CSS-Tricks) — https://css-tricks.com/almanac/properties/w/height/
- box-sizing (MDN) — https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing