Latest web development tutorials
 

Style minWidth Property

< Style Object

Example

Set the minimum width of a <div> element:

document.getElementById("myDIV").style.minWidth = "400px";
Try it Yourself »

Definition and Usage

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

The minWidth property has effect only on block-level elements or on elements with absolute or fixed position.

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


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The minWidth property is supported in all major browsers.


Syntax

Return the minWidth property:

object.style.minWidth

Set the minWidth property:

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

Property Values

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

Technical Details

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

More Examples

Example

Return the minimum width of a <p> element:

alert(document.getElementById("myP").style.minWidth);
Try it Yourself »

Related Pages

CSS tutorial: CSS Dimension

CSS reference: min-width property


< Style Object