CSS Property min-width








min-width sets a minimum constraint on the width of the element.

Summary

ItemValue
Initial value 0
Inherited No.
Version CSS2
JavaScript syntax object.style.minWidth="5px"
Applies to All elements except inline nonreplaced elements and table elements.




CSS Syntax

min-width: length | percentage | inherit 

Property Values

The property values are listed in the following table.

ValueDescription
auto Default value. The browser does the calculation.
length Set width in px, cm, etc.
% Set width in percent of the containing element
inherit Inherit the width property from the parent element

Browser compatibility

Yes Yes Yes Yes Yes




Example

An example showing how to use min-width CSS property.

<!DOCTYPE HTML>
    <html>
        <head>
            <title></title>
            <style type='text/css'>
        p {<!--from www.j  a  v a 2  s .  co m-->
            padding: 10px;
            margin: 10px;
            border: thin solid black;
            width: auto;
            min-width: 200px;
        }
            </style>
        </head>
        <body>
      <p>
this is a test. this is a test. 
this is a test. this is a test. this is a test. 
this is a test. this is a test. 
this is a test. this is a test. this is a test. 
this is a test. this is a test. 
this is a test. this is a test. 
      </p>
        </body>
    </html>

Click to view the demo