CSS Properties Index Positioning Properties
Sets or retrieves the width of the object.
CSS |
{ width: 'auto' | length | percentage } |
Script |
object.style.width = sWidth ] |
auto |
Default width. |
length |
Floating-point number and a valid CSS length unit: either an absolute units designator ( cm, mm, in, pt, pc, or px ) or a relative units designator ( em or ex ). |
percentage |
Value expressed as a percentage of the parent object’s width. |
The property is read/write with a default value of auto; the CSS attribute is not inherited.
The width of a block object encompasses borderLeft, borderRight, paddingLeft, paddingRight, marginLeft, marginRight, and width—the sum of which equals the width of the parent's content.
Percentage values refer to the parent object’s width. Negative values are not allowed.
To carry out operations on the numeric value of this property, use pixelWidth or posWidth.
For more information on how to access the dimension and location of elements on the page through the document object model, see Measuring Element Dimension and Location.