min-width
Set the minimum width of a <span> element to 500 pixels:
span.ex1
{
min-width: 500px;
}
Try it Yourself »
Definition min-width
The min-width
property defines the minimum width of an element.
If the content is smaller than the minimum width, the minimum width will be applied.
If the content is larger than the minimum width, the min-width
property has no effect.
Note: This prevents the value of the width property from becoming smaller than min-width
.
Default value: | 0 |
---|---|
Inherited: | no |
Animatable: | yes, see individual properties. Read about animatable Try it |
Version: | CSS2 |
JavaScript syntax: | object.style.minWidth="400px" Try it |
Browser Support min-width
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
min-width | 1.0 | 7.0 | 1.0 | 2.0.2 | 4.0 |
CSS Syntax min-width
min-width: length|initial|inherit;
Property Values min-width
Value | Description | Demo |
---|---|---|
length | Default value is 0. Defines the minimum width in px, cm, etc. Read about length units | Demo ❯ |
% | Defines the minimum width in percent of the containing block | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Related Pages min-width
CSS tutorial: CSS Height and Width
CSS reference: max-width property
HTML DOM reference: minWidth property