Fandom

HTML & CSS Wiki

Max-width

649pages on
this wiki
Add New Page
Comments0 Share

The max-width property is used in CSS and certain HTML elements. This property allows a maximum width to be set for an element box. The calculation for the element's width may be less than this value, but if the calculated width value is above this value it will recompute the width using the max-width value as the new width value. If the value of min-width is greater than the value of max-width, the max-width property value becomes the min-width value.

Values

  • inherit - Explicitly sets the value of this property to that of the parent.
  • none - No limit is placed on the maximum allowable width for the element.
  • <length> - Refers to an absolute measurement for the maximum computed element box width. Negative values are not allowed. Examples of lengths are px, em, etc.
  • <percentage> - Refers to a percentage of the width of the containing element block.


HTML example:

<h1 style="max-width:500px;">
H1 content.
</h1>


CSS example:

h1 {
    max-width:500px;
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.