Learn
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.

Instructions

1.

Again, resize your browser (stretch it out). Notice that the paragraph’s text can become overly spread out (i.e. a small height). Let’s limit the height to keep the text legible.

In style.css, set the minimum height of all paragraphs to 200 pixels.

Resize your browser once more and notice that the text no longer spreads out as much as it did before.

Folder Icon

Sign up to start coding

Already have an account?