You are here: Reference > CSS > properties > min-width

min-width property

Browser support:
7
Specifies the minimum 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 min-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 less than the value specified by the min-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: minWidth. You can find other example(s) there.

Possible values:

 One of the following values: 
inherit
Takes the value of this property from the computed style of the parent element.
width in non-negative length
The minimum width for the element in length units. For the supported length units, see the length page.
width in non-negative percentage
The minimum width for the element is the specified percentage of the width of the parent element.
Default: 0.

Example HTML code 1:

This example illustrates the use of the min-width property:
<head>
    <style>
        .minWidth {
            width: 100px;
            min-width: 200px;
            background: red;
        }

        .widthOnly {
            width: 100px;
            background: red;
        }
    </style>
</head>
<body>
    <p class="minWidth">
        Element has width: 100px and min-width: 200px. <br />
        As a result, it should be 200 pixels wide.
    </p>
    <p class="widthOnly">
        Element has width: 100px and min-width: 200px. <br />
        As a result, it should be 200 pixels wide.
    </p>
</body>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content