CSS Width and Height
CSS Width/Height
- Used to set the width and height of an element.
- Values can be specified in
auto
: default value, browser calculates the width
length
: in px, cm
%
: in percent of containing block
width: auto;
width: 100px;
width: 50%;
height: auto;
height: 100px;
height: 50%;
max-width/max-height
- Defines the maximum width of an element.
- Can be specified in length values like px, cm, etc., or in percent (%) of the containing block, or set to none (default)
- If the content is larger than the maximum width, then the maximum width will be applied.
- If the content is smaller than the maximum width, the
max-width
property has no effect.
min-width/min-height
- Defines the minimum width of an element.
- If the content is smaller than the minimum width, the minimum width will be applied.
- If the content is larger than the minimum width, the
min-width
property has no effect.