Code Editor
Web Browser
Understanding the Box Model

Height: Minimum & Maximum

You can also limit the minimum and maximum height of an element.

  1. min-height - this property ensures a minimum height for an element's box.
  2. max-height - this property ensures a maximum height for an element's box.
p { min-height: 150px; max-height: 300px; }

In the example above, the height of all paragraphs will not shrink below 150 pixels and the height will not exceed 300 pixels.

What will happen to the contents of an element's box if the max-height property is set too low? It's possible for the content to spill outside of the box, resulting in content that is not legible. You'll learn how to work around this issue in the next exercise.

Report a Bug
If you see a bug or any other issue with this page, please report it here.