Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. max-width

max-width

Specifies the maximum width of an element.

Sample Code

p.test { max-width: 500px;}
p.test1 { max-width: none;}

Available Values

ValueDescription
noneNo maximum value is specified. The initial value is 'none'.
numberA numeric value. Commonly used units are 'px' and '%'. Negative values are not allowed. When specified as '%', the reference size is the width of the containing block.

Browser Display Result

<div style="max-width: 500px; background-color: #ff0;">This is a div element. 'max-width: 500px' is specified.</div>

<div style="width: 500px; border: solid 1px #f00;">
	<div style="max-width: 80%; width: 500px; background-color: #ff0;">This is a div inside a div. The parent div (red border) has 'width: 500px'. This element (yellow background) has 'max-width: 80%' and 'width: 500px'. Its maximum width is relative to the parent's width, giving a maximum of '400px'. Since '400px' is less than 'width: 500px', this element's width becomes '400px'.</div>
</div>

Browser Compatibility

Chrome Chrome
1+
Firefox Firefox
1+
Safari Safari
1+
Edge Edge
12+
Supported in all versions
IE IE
11
10
9
8
7
6 ×
Opera Opera
4+
3 and earlier ×
iOS Safari iOS Safari
1+
Android Android Browser
4.4+
3 and earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop
Firefox Android Firefox Android
Latest
Same support as desktop

※ Version data is based on MDN.

If you find any errors or copyright issues, please .