Set the width of a <button> element:
The width property sets or returns the width an element.
The width property has effect only on block-level elements or on elements with absolute or fixed position. The overflowing content can be manipulated with the overflow property.
Tip: Use the height property to set or return the height of an element.
The width property is supported in all major browsers.
Return the width property:
Set the width property:
Value | Description |
---|---|
auto | The browser sets the width. This is default |
length | Defines the width in length units |
% | Defines the 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 |
Default Value: | auto |
---|---|
Return Value: | A String, representing the width of an element |
CSS Version | CSS1 |
Change the width of a <div> element:
Change the height and width of an <img> element:
Return the width of an <img> element:
CSS tutorial: CSS Dimension
CSS tutorial: CSS Box model
CSS reference: width property