Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style minWidth Property

Style minWidth Property

Style Object Reference The Style object


Definition and Usage

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

The minWidth property only takes effect on block-level elements or absolutely/fixed-positioned elements.

Syntax

Sets the minWidth property:

Object.style.minWidth="

length|%

|inherit"

Returns the minWidth property:

Object.style.minWidth

Value Description
length Defines the minimum width using units such as px, cm, etc. The default is 0.
% Defines the minimum width as a percentage of the parent element.
inherit The minWidth property value is inherited from the parent element.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the minWidth property.

**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Sets the minimum width of an element:

Runoob Tutorial(runoob.com)

This paragraph has a width of 100px.

When the button below is clicked,

The minimum width is set to 200px,

Therefore, this paragraph is 200 pixels wide

Try it »


Style Object Reference The Style object