max-width property
7 | ||||
Specifies the maximum width for the visible area of an element.
This property has effect only on block-level elements or on elements with absolute or fixed position.
The max-width property contains only the pure width of the visible content, without the padding, scrollbar, border and the margin.
The width of an element can never be greater than the value specified by the max-width property.
Note that this property works in Internet Explorer only from version 7.
You can specify a range for the size of an element with the min-width, min-height, max-width and max-height properties.
If you want to specify the exact size of an element, use the width and height properties.
JavaScript page for this property: maxWidth. You can find other example(s) there. |
Possible values:
One of the following values:
Takes the value of this property from the computed style of the parent element. | |||||||
No limit on the width of the element. | |||||||
The maximum width for the element in length units. For the supported length units, see the length page. | |||||||
The maximum width for the element is the specified percentage of the width of the parent element. |
Default: none.
Example HTML code 1:
This example illustrates the use of the max-width property:
|
||||
<head> <style> .withMax { max-width: 50px; width: 100px; background: red; } .withouMax { width: 100px; background: red; } </style> </head> <body> <p class="withMax"> width: 100px and max-width: 50px. As a result, it should be 50 pixels wide. </p> <p class="withouMax"> width: 100px. As a result, it should be 100 pixels wide. </p> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by tags:
address, blockQuote, body, center, dd, dir, div, dl, dt, fieldSet, form, H1, H2, H3, H4, H5, H6, hr, iframe, img, input:button, input:file, input:image, input:password, input:reset, input:search, input:submit, input:text, isIndex, legend, li, listing, marquee, menu, ol, p, plainText, pre, select, table, textArea, ul, xmp
Related pages:
External links:
max-width (MSDN)
max-width (Mozilla Developer Center)
max-width (Safari Reference Library)
max-width (W3C)
max-width (Mozilla Developer Center)
max-width (Safari Reference Library)
max-width (W3C)
User Contributed Comments