Skip to content

Synchronize .width() and .height() documentation #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions entries/height.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
</p>
<p>This method is also able to find the height of the window and document.</p>
<pre><code>
$( window ).height(); // returns height of browser viewport
$( document ).height(); // returns height of HTML document
// Returns height of browser viewport
$( window ).height();

// Returns height of HTML document
$( document ).height();
</code></pre>
<p>Note that <code>.height()</code> will always return the content height, regardless of the value of the CSS <code>box-sizing</code> property. As of jQuery 1.8, this may require retrieving the CSS height plus <code>box-sizing</code> property and then subtracting any potential border and padding on each element when the element has <code>box-sizing: border-box</code>. To avoid this penalty, use <code>.css( "height" )</code> rather than <code>.height()</code>.</p>
<div class="warning">
Expand Down
3 changes: 3 additions & 0 deletions entries/width.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ $( window ).width();
$( document ).width();
</code></pre>
<p>Note that <code>.width()</code> will always return the content width, regardless of the value of the CSS <code>box-sizing</code> property. As of jQuery 1.8, this may require retrieving the CSS width plus <code>box-sizing</code> property and then subtracting any potential border and padding on each element when the element has <code>box-sizing: border-box</code>. To avoid this penalty, use <code>.css( "width" )</code> rather than <code>.width()</code>.</p>
<div class="warning">
<p><strong>Note:</strong> Although <code>style</code> and <code>script</code> tags will report a value for <code>.width()</code> or <code>height()</code> when absolutely positioned and given <code>display:block</code>, it is strongly discouraged to call those methods on these tags. In addition to being a bad practice, the results may also prove unreliable.</p>
</div>
</longdesc>
<example>
<desc>Show various widths. Note the values are from the iframe so might be smaller than you expected. The yellow highlight shows the iframe body.</desc>
Expand Down