CSS width Property
CSS width property specifies the width of the content area of an element.
Usages
The following table outline the usages and version history of this property.
| Default value: | auto |
| Applies to: | All elements except table rows |
| Inherited: | No |
| Version: | CSS1 |
| JavaScript Syntax: | object.style.width = "200px" |
Syntax
Here is a syntax for the CSS width property
width: auto | length | percentage | initial | inherit;
Property Values
The following table describes the values of this property.
| Value | Description |
|---|---|
| auto | Default. Browser will calculate the width for the element |
| length | Specifies the length value expressed in px, pt, cm, em, etc. to set width Negative values are not allowed. |
| percentage | Specifies the percentage value to set width |
| initial | Sets default value of this property |
| inherit | Inherits this property from its parent element |
Examples
The example below shows to sets width property.
div.one {
width: auto;
}
div.two {
width: 200px;
}
Browser Compatibility
- Google Chrome 1+
- Mozilla Firefox 1+
- Internet Explorer 4+
- Opera 7+
- Safari 1+
Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.