Width & Height
Fixed Dimensions
Use width and height to set exact dimensions in
pixels, ems, or other units.
Percentage Widths
Percentages are relative to the parent element's width. Great for responsive designs!
Min and Max Width
min-width and max-width set boundaries for
responsive elements. The element can grow or shrink within these
limits.
Min and Max Height
Similarly, min-height and max-height
control vertical boundaries.
Auto and 100%
width: auto (default) sizes based on content.
width: 100% fills the parent container.
max-width: 100% on images to prevent
them from overflowing their containers on small
screens.
Summary
width/height- Set exact dimensions- Use
%for responsive, fluid layouts min-width/max-width- Set size boundariesmin-height/max-height- Control vertical limitswidth: 100%- Fill parent containerwidth: auto- Size based on content (default)
Quick Quiz
Which property prevents an element from growing beyond 800px wide?
Enjoying these tutorials?