min-width
Description
min-width
sets a minimum constraint on the width of the element.
Item | Value |
---|---|
Initial value | 0 |
Inherited | No. |
Version | CSS2 |
JavaScript syntax | object.style.minWidth="5px" |
Applies to | All elements except inline nonreplaced elements and table elements. |
Syntax and Property Values
min-width: length | percentage | inherit
The property values are listed in the following table.
Value | Description |
---|---|
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 |
Example
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<style type='text/css'>
p {<!-- w ww . j a v a 2s.c om-->
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>
The code above generates the following result.