</> Code Corner

CSS · CSS Tutorial · Lesson 11

CSS Height / Width

Set element size, with min and max limits.

The height and width properties set the size of an element's content area (not including padding, border or margin).

Example

<style>
.box { height: 100px; width: 50%; background-color: powderblue; }
.limited { max-width: 400px; min-height: 60px; background: lightsalmon; margin-top: 10px; }
</style>
<div class="box">height 100px, width 50%</div>
<div class="limited">max-width 400px</div>
Value Meaning
auto Browser calculates (default)
px, cm, em… Fixed length
% Percent of the containing block
max-width / min-width Upper / lower limit

Keep reading “CSS Height / Width”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋