freecoding.school100% FREE · NO SIGNUP
Cascade FallsISSUE #21 of 33

height and width · sizing basics

StylaVSThe Specificity Sphinx
Styla sayswidth and height size an element; min/max variants set flexible bounds.

width and height set explicit sizes. More useful for responsive work: max-width caps growth (so content doesn't sprawl on wide screens) while letting it shrink, and min-width/min-height set floors. max-width: 100% keeps images from overflowing.

Power-ups you unlock

The Specificity Sphinx attacks — common mistakes

Boss battleCap a content column at max-width 600px centered, and make an image never exceed its container.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>.col{max-width:600px;margin:0 auto;color:#e6e0ff}img{max-width:100%}</style></head><body style="background:#06040d;padding:20px"><div class="col"><p>a readable, capped column.</p><img src="https://via.placeholder.com/1200x200" alt=""></div></body></html>
▶ Open the interactive comic issue
‹ Padding · The Inner SpaceBox Model · Content · Padding · Border · Margin ›