Sizing Elements

Height: Minimum & Maximum

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

  1. min-height — ensures a minimum height for an element's box.
  2. max-height — 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 if the max-height property is set too low for that element? It's possible that content will overflow outside of the element, resulting in content that is not legible.

Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.