Skip to content
Justice Tech School

min and max Width and Height

max-width stops a box growing too wide while letting it shrink. min-height lets a box grow with its content. These make flexible, readable layouts.

Example
<style>
.c { max-width: 220px; min-height: 40px; background: #0f766e; padding: 8px; margin: auto }
</style>
<div class="c">This box never grows past 220px but shrinks on small screens.</div>

Exercise

Limit the width.

-width: 600px;

Quiz Test

Which makes a box shrink on phones?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.