Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 508823 of HTMLElement.offsetWidth

  • Revision slug: Web/API/HTMLElement.offsetWidth
  • Revision title: HTMLElement.offsetWidth
  • Revision id: 508823
  • Created:
  • Creator: saneyuki_s
  • Is current revision? No
  • Comment

Revision Content

{{ DomRef() }}

Summary

Returns the layout width of an element.

Syntax

var offsetWidth =element.offsetWidth;

offsetWidth is a read-only property.

Description

Typically, an element's offsetWidth is a measurement which includes the element borders, the element horizontal padding, the element vertical scrollbar (if present, if rendered) and the element CSS width.

Example

padding-top

Gentle, individualistic and very loyal, Birman cats fall between Siamese and Persian in character. If you admire cats that are non aggressive, that enjoy being with humans and tend to be on the quiet side, you may well find that Birman cats are just the felines for you.

Image:BirmanCat.jpgAll Birmans have colorpointed features, dark coloration of the face, ears, legs and tail.

Cat image and text coming from www.best-cat-art.com

padding-bottom

LeftTopRightBottommargin-topmargin-bottomborder-topborder-bottom{{ mediawiki.external('if IE') }}><span id="MrgLeft" style="position: absolute; left: 8px; top: 65px; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">margin-left</span><span id="BrdLeft" style="position: absolute; left: 33px; top: 65px; color: white; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">border-left</span><span id="PdgLeft" style="position: absolute; left: 55px; top: 65px; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">padding-left</span><span id="PdgRight" style="position: absolute; left: 275px; top: 60px; color: black; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl; white-space: nowrap;">padding-right</span><span id="BrdRight" style="position: absolute; left: 310px; top: 65px; color: white; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">border-right</span><span id="MrgRight" style="position: absolute; left: 340px; top: 65px; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">margin-right</span><!{{ mediawiki.external('endif') }}

Image:offsetWidth.png

Specification

Specification Status Comment
{{SpecName('CSSOM View', '#dom-htmlelement-offsetwidth', 'focus')}} {{Spec2('CSSOM View')}}  
MSIE's DHTML Non-Standard The part of the MSIE's DHTML object model.

Notes

offsetWidth is a property of the DHTML object model which was first introduced by MSIE. It is sometimes referred to as an element's physical/graphical dimensions, or an element's border-box width.

References

  • {{ MSDN("ms534304", "offsetWidth Property") }}
  • {{ MSDN("hh781509", "Measuring Element Dimension and Location") }}

See also

 

{{ languages( { "fr": "fr/DOM/element.offsetWidth", "pl": "pl/DOM/element.offsetWidth" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<h2 id="Summary" name="Summary">Summary</h2>
<p>Returns the layout width of an element.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
var<i> offsetWidth</i> =<i>element</i>.offsetWidth;
</pre>
<p><code>offsetWidth</code> is a read-only property.</p>
<h2 id="Description" name="Description">Description</h2>
<p>Typically, an element's <code>offsetWidth</code> is a measurement which includes the element borders, the element horizontal padding, the element vertical scrollbar (if present, if rendered) and the element CSS width.</p>
<h2 id="Example" name="Example">Example</h2>
<div id="offsetContainer" style="margin: 26px 0px; background-color: rgb(255, 255, 204); border: 4px dashed black; color: black; position: absolute; left: 260px;">
 <div id="idDiv" style="margin: 24px 29px; border: 24px black solid; padding: 0px 28px; width: 199px; height: 102px; overflow: auto; background-color: white; font-size: 13px!important; font-family: Arial, sans-serif;">
  <p id="PaddingTopLabel" style="text-align: center; font-style: italic; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif; margin: 0px;">padding-top</p>
  <p>Gentle, individualistic and very loyal, Birman cats fall between Siamese and Persian in character. If you admire cats that are non aggressive, that enjoy being with humans and tend to be on the quiet side, you may well find that Birman cats are just the felines for you.</p>
  <p><span style="float: right;"><img alt="Image:BirmanCat.jpg" fileid="44" src="File:en/Media_Gallery/BirmanCat.jpg" /></span>All Birmans have colorpointed features, dark coloration of the face, ears, legs and tail.</p>
  <p>Cat image and text coming from <a class="external" href="https://www.best-cat-art.com/">www.best-cat-art.com</a></p>
  <p id="PaddingBottomLabel" style="text-align: center; font-style: italic; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif; margin: 0px;">padding-bottom</p>
 </div>
 <span style="position: absolute; left: -32px; top: 85px; color: blue; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif;">Left</span><span style="position: absolute; left: 170px; top: -24px; color: blue; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif;">Top</span><span style="position: absolute; left: 370px; top: 85px; color: blue; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif;">Right</span><span style="position: absolute; left: 164px; top: 203px; color: blue; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif;">Bottom</span><span style="position: absolute; left: 143px; top: 5px; font-style: italic; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif;">margin-top</span><span style="position: absolute; left: 138px; top: 175px; font-style: italic; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif;">margin-bottom</span><span style="position: absolute; left: 143px; top: 27px; color: white; font-style: italic; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif;">border-top</span><span style="position: absolute; left: 138px; top: 153px; color: white; font-style: italic; font-weight: bold; font-size: 13px!important; font-family: Arial, sans-serif;">border-bottom</span><span class="comment">{{ mediawiki.external('if IE') }}&gt;&lt;span id="MrgLeft" style="position: absolute; left: 8px; top: 65px; font: bold 13px Arial, sans-serif&nbsp;!important; writing-mode: tb-rl;"&gt;margin-left&lt;/span&gt;&lt;span id="BrdLeft" style="position: absolute; left: 33px; top: 65px; color: white; font: bold 13px Arial, sans-serif&nbsp;!important; writing-mode: tb-rl;"&gt;border-left&lt;/span&gt;&lt;span id="PdgLeft" style="position: absolute; left: 55px; top: 65px; font: bold 13px Arial, sans-serif&nbsp;!important; writing-mode: tb-rl;"&gt;padding-left&lt;/span&gt;&lt;span id="PdgRight" style="position: absolute; left: 275px; top: 60px; color: black; font: bold 13px Arial, sans-serif&nbsp;!important; writing-mode: tb-rl; white-space: nowrap;"&gt;padding-right&lt;/span&gt;&lt;span id="BrdRight" style="position: absolute; left: 310px; top: 65px; color: white; font: bold 13px Arial, sans-serif&nbsp;!important; writing-mode: tb-rl;"&gt;border-right&lt;/span&gt;&lt;span id="MrgRight" style="position: absolute; left: 340px; top: 65px; font: bold 13px Arial, sans-serif&nbsp;!important; writing-mode: tb-rl;"&gt;margin-right&lt;/span&gt;&lt;!{{ mediawiki.external('endif') }}</span></div>
<p style="margin-top: 270px;"><img alt="Image:offsetWidth.png" fileid="791" src="File:en/Media_Gallery/OffsetWidth.png" /></p>
<h2 id="Specification" name="Specification">Specification</h2>
<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSSOM View', '#dom-htmlelement-offsetwidth', 'focus')}}</td>
   <td>{{Spec2('CSSOM View')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>MSIE's DHTML</td>
   <td>Non-Standard</td>
   <td>The part of the MSIE's <abbr title="Dynamic HyperText Markup Language">DHTML</abbr> object model.</td>
  </tr>
 </tbody>
</table>
<h2 id="Notes" name="Notes">Notes</h2>
<p><code>offsetWidth</code> is a property of the <abbr title="Dynamic HyperText Markup Language">DHTML</abbr> object model which was first introduced by MSIE. It is sometimes referred to as an element's physical/graphical dimensions, or an element's border-box width.</p>
<h2 id="References" name="References">References</h2>
<ul>
 <li>{{ MSDN("ms534304", "offsetWidth Property") }}</li>
 <li>{{ MSDN("hh781509", "Measuring Element Dimension and Location") }}</li>
</ul>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
 <li><a href="/en-US/docs/DOM/element.clientWidth">DOM:element.clientWidth</a></li>
 <li><a href="/en-US/docs/DOM/element.scrollWidth">DOM:element.scrollWidth</a></li>
 <li><a href="/en-US/docs/Determining_the_dimensions_of_elements">Determining the dimensions of elements</a></li>
</ul>
<div class="noinclude">
 &nbsp;</div>
<p>{{ languages( { "fr": "fr/DOM/element.offsetWidth", "pl": "pl/DOM/element.offsetWidth" } ) }}</p>
Revert to this revision