Style minWidth Property

Definition and Usage

minWidth Property sets or returns the minimum width of an element.

minWidth This property is only valid for block-level elements or elements with absolute or fixed positioning.

Tip:To set or return the maximum width of an element, use maxWidth property.

See also:

CSS Tutorial:CSS Dimension

CSS Reference Manual:min-width property

Example

Example 1

Set the minimum width of the <div> element:

document.getElementById("myDIV").style.minWidth = "400px";

Try it yourself

Example 2

Return the minimum width of the <p> element:

alert(document.getElementById("myP").style.minWidth);

Try it yourself

Syntax

Return minWidth property:

object.style.minWidth

Set minWidth property:

object.style.minWidth = "length|%|initial|inherit"

Property value

Value Description
length Define the minimum width in length units. The default is 0.
% Define the minimum width in percentage of the parent element.
initial Set this property to its default value. See also initial.
inherit Inherit this property from its parent element. See also inherit.

Technical details

Default value: 0
Return value: A string representing the minimum width of an element.
CSS version: CSS2

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support