asp.net.ph

Skip Navigation Links

width Attribute | width Property

CSS Properties Index   Positioning Properties


Sets or retrieves the width of the object.

Syntax


CSS { width: 'auto' | length | percentage }
Script object.style.width = sWidth ]

Possible Values


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.

Remarks

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.



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note