YouTip LogoYouTip

Prop Style Minwidth

# Style minWidth Property [![Image 8: Style Object Reference](#) Style Object](#) * * * ## Definition and Usage The minWidth property sets or returns the minimum width of an element. The minWidth property only works on block-level elements or absolutely/fixed positioned elements. ## Syntax Set the minWidth property: Object.style.minWidth="_length|%_|inherit" Return the minWidth property: Object.style.minWidth | Value | Description | | :--- | :--- | | _length_ | Defines the minimum width in units like px, cm, etc. Default is 0. | | _%_ | Defines the minimum width as a percentage of the parent element. | | inherit | The value of the minWidth property is inherited from its parent element. | * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) The minWidth property is supported by all major browsers. **Note:** IE7 and earlier versions do not support the "inherit" value. IE8 only supports "inherit" if a !DOCTYPE is specified. IE9 supports "inherit". * * * ## Example ## Example Set the minimum width of an element: function displayResult(){ document.getElementById("p1").style.minWidth="200px"; }

This paragraph has a width of 100px.
When you click the button below,
the minimum width is set to 200px,
so this paragraph becomes 200 pixels wide.

[Try it Β»](#) * * Style Object](#)
← Prop Style DirectionProp Style Minheight β†’