min-width

Sets the minimum width for an element.

Syntax

{ min-width: sMinWidth }

Possible values

sMinWidth

Variant that specifies the minimum width for an element:

length

Floating-point number followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px).

For more information about the supported length units, see Length units reference.

percentage

Integer followed by a percent sign (%) that specifies a percentage of the containing block height to use as the maximum height of the element. If the height of the containing block is not explicitly set, the element has no maximum height and the max-height property is interpreted as 0%. For more information about containing blocks and how their heights are computed, see the Cascading Style Sheets (CSS), Level 2, Revision 1 (CSS2.1) Ee371243.xtlink_newWindow(en-us,Expression.40).png specification.

The property has no default value. It is not inherited.

Remarks

The min-width and max-width attributes apply to floating and absolutely positioned block level elements and inline-block elements, and also to some intrinsic controls. They do not apply to non-replaced inline elements, such as table rows and row/column groups. (A "replaced" element has intrinsic dimensions, such as an IMG element or a TEXTAREA element.)

This property is enabled only under the strict !DOCTYPE.

Example

The following example shows how to constrain the width of a DIV element using min-width and max-width attributes. The example can be viewed only with Microsoft Internet Explorer 7 or a later version:

<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Strict//EN">
<html>
<head><style>
.width {
    width:50%;
    min-width:200px;
    max-width:400px;
    background:#eee;
}
.content {
    border :1px solid #c00;
    padding:5px;
}
</style>
</head>
<body>
<div class="width">
<div class="content">
        <h2>{min-width:200px; max-width:400px}</h2>
        <p>This div has a width of 50%. Resize the window
         to grow and shrink the div from max to min width.<br/><br/>
         The outer div controls the width of the inner "content" div.
         Note that the div height increases to accomodate the flow of text.</p>
</div>
</div>
</body>
</html>

Standards information

This property is defined in Cascading Style Sheets (CSS), Level 2 (CSS2) Ee371243.xtlink_newWindow(en-us,Expression.40).png.

Applies to

a, abbr, acronym, b, bdo, big, blockquote, body, button, caption, center, cite, code, custom, dd, defaults, del, dfn, div, dl, dt, em, embed, fieldset, font, form, frameset, frame, hn, i, iframe, img, input type=button, input type=checkbox, input type=file, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, ins, li, object, ol, p, q, s, span, sub, table, td, th, tt, u, ul, var, xmp

See also

Concepts

max-width

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.