Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
Properties
 clientWidth Property
clientWidth Property

Retrieves the width of the object including padding, but not including margin, border, or scroll bar.

Syntax

HTMLN/A
Scripting[ iWidth = ] object.clientWidth

Possible Values

iWidthInteger that receives the width of the object, in pixels.

The property is read-only. The property has no default value.

Example

This example shows how the clientWidth property and the offsetWidth property measure document width differently. The width of the div is set to 200, and this is the value retrieved by the offsetWidth property, not the clientWidth property.

<DIV ID=oDiv STYLE="overflow:scroll; width:200; height:100"> . . . </DIV>
<BUTTON onclick="alert(oDiv.clientWidth)">client width</BUTTON>
<BUTTON onclick="alert(oDiv.offsetWidth)">offset widthY</BUTTON>
This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

There is no public standard that applies to this property.

Applies To

A, ADDRESS, APPLET, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, CUSTOM, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FORM, hn, HTML, I, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, META, NOBR, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP

See Also

Measuring Element Dimension and Location
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
UNRELIABLE      george_5154 ... Thomas Lee   |   Edit   |  

IE does not provide a simple way to accurately retrieve the size of a document! document.documentElement.clientWidth reports 0 (zero) in some cases, while document.body.clientWidth also reports 0 in others. In some cases clientWidth may report the width of the object minus the size of the scrollbar, even when there is no scrollbar on the screen.

Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker