bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/CSS/CSS Foundations
CSS•CSS Foundations

CSS Min/Max Height and Width

Flash cards

Review the key moves

1/3
Core idea

What is the main idea behind CSS Min/Max Height and Width?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Order

Put the learning moves in the order that makes the concept easiest to apply.

All CSS Dimension Properties
CSS Using max-width
CSS Min/Max Height and Width

The min-width and max-width properties are used to set the minimum and maximum width of an element.

The min-height and max-height properties are used to set the minimum and maximum height of an element.

CSS Using max-width

The max-width property sets the maximum allowed width of an element. This prevents the width of an element to be larger than the max-width property value.

The max-width property can have the following values:

  • length - Defines the maximum width in px, cm, etc.
  • % - Defines the maximum width in percent of the containing block
  • none - This is default. Means that there is no maximum width

One problem with the width property can occur when the browser window is smaller than the width of the element. The browser then adds a horizontal scrollbar to the page. So, using max-width will improve the browser's handling on small windows.

All CSS Dimension Properties

PropertyDescription
heightSets the height of an element
max-heightSets the maximum height of an element
max-widthSets the maximum width of an element
min-heightSets the minimum height of an element
min-widthSets the minimum width of an element
widthSets the width of an element

Previous

CSS Height and Width

Next

CSS Box Model