minWidth Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:minWidth

Description

The minWidth property sets or gets the minimum width of an element.

Property Values

Value Description
length minimum width in length units. Default is 0
% minimum width in percentage of the parent element
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: 0
Return Value: A String, representing the minimum width of an element
CSS VersionCSS2

Set the minimum width of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p style="background:red;min-width:600px;" id="myP">The minimum width of this paragraph is set to 600px.</p>

<button type="button" onclick="myFunction()">test</button>

<script>
function myFunction() {/*from w  ww .  jav  a2s . co  m*/
    document.getElementById("myP").style.minWidth = '400px';
}
</script>

</body>
</html>

Related Tutorials