width | NN 4 IE 4 CSS 1 |
Inherited: No | |
Sets the width of a block-level, replaced, and positioned element's content width (exclusive of borders, padding, and margins). IE for Windows counts left and right margins, padding, and borders when calculating the width of an element until you reach IE 6 in standards compatibility mode (see the DOCTYPE element in Chapter 8). When observing the CSS standards, the width applies to only the content portion of an element, irrespective of borders, padding, or margins. This change may have significant impact on legacy code that you are bringing up to W3C compatibility. |
|
CSS Syntax | |
width: length | percentage | auto |
|
Value | |
See the discussion about length values at the beginning of this chapter. The setting of auto lets the browser determine the width of the element box based on the amount of space required to display the content within the current window width. |
|
Initial Value | |
auto |
|
Example | |
div#announce {position: relative; left: 30; width: 240} textarea {width: 80%} |
|
Applies To | |
Navigator 4, all absolute-positioned elements; Internet Explorer 4, applet, div, embed, fieldset, hr, iframe, img, input, marquee, object, span, table, and textarea elements; Internet Explorer 5 and Netscape 6, all elements except nonreplaced inline elements, table column elements, and column group elements. |
|
Object Model Reference | |
[window.]document.getElementById("elementID").style.width
|