max-width

The max-width property constrains the width of an element to a maximum range.

CSS2

Syntax

max-width: <length> | <percentage> | none | inherit
Initial: none
Applies To: all elements but non-replaced inline elements, table rows, and row groups
Inherited: no
Percentages: refer to width of containing block
Media: visual

Values

max-width: value
Value Description
length Fixed maximum width
none No width limit
percentage Width percentage calculated with respect to the width of the containing block

DOM

[window.]document.getElementById("element-id").style.maxWidth = "max-width";

Example | length

Example | none

Example | percentage

Example | DOM

External

W3C Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification