width
The width property specifies the content width of boxes generated by block-level and replaced elements.
Syntax
width: <length> | <percentage> | auto | inherit
Initial: | auto |
Applies To: | all elements but non-replaced inline elements, table rows, and row groups |
Inherited: | no |
Percentages: | refer to width of containing block |
Media: | visual |
Values
width: value
Value | Description |
---|---|
auto | Depends on the values of other properties |
length | Width measurement: em | ex | px | in | cm | mm | pt | pc |
percentage | Width percentage calculated with respect to the width of the containing block |
DOM
[window.]document.getElementById("element-id").style.width = "width";
Example | auto
Example | length
Example | percentage
Example | DOM
External
W3C Cascading Style Sheets, level 1
W3C Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification