---
title: Document.width
slug: Web/API/Document/width
translation_of: Web/API/Document/width
---
<div>{{APIRef("DOM")}} {{Obsolete_header}}</div>

<div class="note">
<p><strong>Remarque:</strong> À partir de {{Gecko("6.0")}},<code> document.width </code>n'est plus pris en charge. Au lieu de cela, utilisez document.body.clientWidth. Voir {{domxref("element.clientWidth")}}.</p>
</div>

<p>Renvoie la largeur de l'élément {{HTMLElement("body")}} du document courrent en pixels.</p>

<p>Non pris en charge par Internet Explorer.</p>

<h2 id="Syntax" name="Syntax">Syntaxe</h2>

<pre class="syntaxbox"><em>pixels</em> = document.width;
</pre>

<h2 id="Example" name="Example">Exemple</h2>

<pre class="brush:js">function init() {
    alert("La largeur du document est " + document.width + " pixels.");
}
</pre>

<h2 id="Alternatives" name="Alternatives">Alternatives</h2>

<pre class="syntaxbox">document.body.clientWidth              /* largeur de &lt;body&gt; */
document.documentElement.clientWidth   /* largeur de &lt;html&gt; */
window.innerWidth                      /* largeur de la fenêtre */
</pre>

<h2 id="Specification" name="Specification">Spécification</h2>

<p>HTML5</p>

<h2 id="See_also" name="See_also">Voir également</h2>

<ul>
 <li>{{domxref("document.height")}}</li>
 <li>{{domxref("Element.clientWidth")}}</li>
 <li>{{domxref("Element.scrollWidth")}}</li>
</ul>