jQuery .outerHeight() Method

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Border box height

What You’ll Learn

The .outerHeight() method gets or sets the height of matched elements including padding and border as a unitless pixel Number — ideal when the full border box matters for layout math and stacking. This tutorial covers the optional includeMargin flag, getter and setter overloads, comparisons with .height(), .innerHeight(), and .outerWidth(), callback setters since 1.8, and practical stack-sum patterns.

01

Getter

.outerHeight() → Number

02

+ Margin

true flag

03

Setter

Since 1.8

04

+ Border

Not margin*

05

Callback

Since 1.8

06

Since 1.2.6

Getter API

Introduction

After learning .innerHeight(), which measures content plus padding, you often need a dimension that also includes border — especially for fixed headers, stacked cards with margins, and subtracting one element’s full footprint from the viewport. jQuery’s .outerHeight() returns a plain number for the border box, ready for math and .animate() without parsing "96px" strings.

Available since jQuery 1.2.6 as a getter, .outerHeight() gained setter and callback forms in jQuery 1.8. Pass true as .outerHeight(true) to include vertical margin in the measurement. Unlike .height(), it does not work on $(window) or $(document) — use it on DOM elements only.

Understanding the .outerHeight() Method

Given a jQuery object, .outerHeight() either returns the current height of the first matched element — content plus vertical padding plus border — as a unitless pixel Number (getter), or sets the CSS height on every matched element so the outer box equals your value (setter). Margin is excluded by default; pass true to include it.

Think of .outerHeight() as a ruler that extends through padding and border. .height() stops at the content edge; .innerHeight() adds padding only; .outerHeight(true) continues through margin. Use .outerHeight() when subtracting a header from the viewport or summing stacked cards — for example, available = $(window).height() - $("#header").outerHeight().

💡
Beginner Tip

On a box with padding: 12px, border: 4px solid, and content height 24px: .height() returns 24, .innerHeight() returns 48, .outerHeight() returns 56. Add .outerHeight(true) to include vertical margin as well.

📝 Syntax

jQuery .outerHeight() has four argument forms — one getter and three setters:

Get — optional includeMargin (since 1.2.6)

jQuery
.outerHeight( [ includeMargin ] )  // -> Number
  • includeMargin — optional Boolean. When true, vertical margin is included in the returned height.
  • Returns the height of the first matched element including padding and border as a unitless pixel Number.
  • Margin excluded by default — pass true to add it.
  • Not for $(window) or $(document) — elements only.
  • Returns undefined when the jQuery set is empty.

Set — Number with optional includeMargin (since 1.8)

jQuery
.outerHeight( value [, includeMargin ] )  // -> jQuery
  • value — target outer height in pixels as a Number (e.g. 60).
  • includeMargin — optional Boolean; when true, margin is factored into the CSS height calculation.
  • jQuery adjusts the CSS height so content plus padding plus border (and optionally margin) equals the value.
  • Returns the original jQuery object for chaining — e.g. .outerHeight(60).addClass("mod").

Set — callback function (since 1.8)

jQuery
.outerHeight( function( index, height ) {
  // return new outer height (Number)
} )
  • index — zero-based position of the element in the matched set.
  • height — current outer height of this element before the change.
  • Return a new outer height per element; jQuery applies it and returns the jQuery object.

Return value

  • Getter — unitless Number (pixels). May be fractional on sub-pixel layouts. Empty set → undefined.
  • Setter — the original jQuery object for chaining.

Important note

⚠️
Hidden elements

.outerHeight() on display:none or hidden elements is unreliable — jQuery may return 0. Measure after showing the element, clone it off-screen, or use a visibility trick before reading.

Official jQuery API example

jQuery
var p = $( "p" ).first();
$( "#result" ).text(
  "outerHeight: " + p.outerHeight() +
  " , outerHeight(true): " + p.outerHeight( true )
);

⚡ Quick Reference

GoalCode
Read border-box height (Number)$("div").outerHeight()
Include vertical margin$("div").outerHeight(true)
Set outer height in pixels$("div").outerHeight(60)
Shrink outer height per click$("div").outerHeight(function(i, h){ return h - 12; })
Content height only (no padding)$("div").height()
Padding only (no border)$("div").innerHeight()
Sum stacked cards with margin$(".card").get().reduce(function(s, el){ return s + $(el).outerHeight(true); }, 0)
Viewport minus fixed header$(window).height() - $("#header").outerHeight()

📋 .outerHeight() vs .innerHeight() vs .height() vs .outerWidth()

Four dimension helpers — content box, padded inner box, full border box, and the horizontal counterpart.

.outerHeight()
+ border

Get/set height including padding and border — pass true to add margin

.innerHeight()
+ pad

Content plus padding — border and margin excluded

.height()
content

Content height only — works on window and document

.outerWidth()
horiz

Horizontal counterpart — width including padding, border, optional margin

Examples Gallery

Examples 1–2 follow the official jQuery API documentation. Examples 3–5 compare dimension methods, demonstrate callback setters, and sum stacked card heights with margin. Use DevTools or the Try-it links to run each snippet.

📚 Getting Started

Official jQuery demos for reading and setting outer height.

Example 1 — Official Demo: Get First Paragraph Outer Height

Read the border-box outer height of the first <p>, with and without margin.

jQuery
var p = $( "p" ).first();
$( "#result" ).text(
  "outerHeight: " + p.outerHeight() +
  " , outerHeight(true): " + p.outerHeight( true )
);
Try It Yourself

How It Works

No-argument .outerHeight() returns a unitless pixel Number for the first element — content height plus vertical padding plus border. Pass true as .outerHeight(true) to add vertical margin to the total.

Example 2 — Official Demo: Set Outer Height on Click

Click each red box once — its outer height is set to modHeight, then modHeight decreases by 8 for the next box.

jQuery
var modHeight = 60;
$( "div" ).one( "click", function() {
  $( this ).outerHeight( modHeight ).addClass( "mod" );
  modHeight -= 8;
});
Try It Yourself

How It Works

.outerHeight(60) sets the CSS height so the outer box (content plus padding plus border) totals 60 pixels. The setter returns the jQuery object, so .addClass("mod") chains immediately. Setter support arrived in jQuery 1.8.

📈 Practical Patterns

Compare dimension APIs, callback setters, and stacked layout math.

Example 3 — Compare .height(), .innerHeight(), and .outerHeight()

See how padding, border, and margin affect each dimension method on the same box.

jQuery
var $box = $( "#box" );
var lines = [
  ".height()              → " + $box.height() + "px (content)",
  ".innerHeight()         → " + $box.innerHeight() + "px (+ padding)",
  ".outerHeight()         → " + $box.outerHeight() + "px (+ border)",
  ".outerHeight(true)     → " + $box.outerHeight( true ) + "px (+ margin)"
];
$( "#out" ).html( lines.join( "<br>" ) );
Try It Yourself

How It Works

All four return unitless Numbers. .height() stops at content; .innerHeight() adds padding; .outerHeight() adds border; .outerHeight(true) adds margin. Pick the method that matches what you are measuring — layout subtraction often uses .outerHeight() on fixed headers.

Example 4 — Callback Setter: Shrink Outer Height by 12px

Each click reduces the panel’s outer height by 12 pixels, with a minimum of 48px.

jQuery
function showVal() {
  $( "#val" ).text( $( "#panel" ).outerHeight() + "px" );
}
showVal();
$( "#panel" ).on( "click", function() {
  $( this ).outerHeight( function( index, height ) {
    return Math.max( 48, height - 12 );
  });
  showVal();
});
Try It Yourself

How It Works

Since jQuery 1.8, the callback setter receives index and the current outer height. Return a new value — here height - 12 with a floor — without manually reading and writing in separate steps.

Example 5 — Sum Card Stack: Total Vertical Space with .outerHeight(true)

Loop through stacked cards and sum each element’s outer height including margin — useful for column layout and scroll-area planning.

jQuery
var sum = 0;
$( ".card" ).each( function() {
  sum += $( this ).outerHeight( true );
});
$( "#total" ).text(
  "Total vertical space (outerHeight with margin): " + sum + "px"
);
Try It Yourself

How It Works

.outerHeight(true) includes margin — essential when summing stacked elements where gaps between cards matter. Without true, margins would be double-counted or missed depending on collapse behavior. This pattern is common for sidebar height estimates and infinite-scroll placeholders.

🚀 Common Use Cases

  • Viewport subtractionavailable = $(window).height() - $("#header").outerHeight() to size content below a fixed header.
  • Stacked card totals — sum .outerHeight(true) across cards to estimate total column height including margins.
  • Dimension debugging — compare .height(), .innerHeight(), and .outerHeight() to trace box-model mismatches.
  • Shrink-on-click UI — callback setter .outerHeight(function(i, h){ return h - 12; }) for interactive panels.
  • Equal outer heights — read each row’s .outerHeight(), find the max, set all to match bordered columns.
  • Animation targets — pair measured .outerHeight() with .animate() when border must stay inside the animated box.

🧠 How .outerHeight() Reads and Writes Dimensions

1

Match elements

jQuery object holds DOM elements — not window or document.

Input
2

Detect mode

No args or true → getter. Number, function, or value + true → setter (1.8+).

Route
3

Measure or apply

Getter reads offsetHeight (content + padding + border). Optional true adds margin. Setter adjusts CSS height to hit the target outer box.

DOM
4

Return result

Getter → unitless pixel Number (or undefined if empty). Setter → same jQuery object for chaining.

📝 Notes

  • Getter available since jQuery 1.2.6 — setter and callback since 1.8.
  • Getter returns a unitless pixel Number from the first matched element only.
  • Includes vertical padding and border — margin excluded unless true is passed.
  • Not for $(window) or $(document) — use .height() on those instead.
  • Empty jQuery set → getter returns undefined.
  • Unreliable on hidden (display:none) elements — may return 0.
  • On border-collapse: collapse tables, per-cell .outerHeight() may be inaccurate — measure the table or use getBoundingClientRect().
  • Values can be fractional (e.g. 86.5) on sub-pixel or zoomed displays.
  • Setter returns the original jQuery object — e.g. .outerHeight(60).addClass("mod").

Browser Support

.outerHeight() getter has been part of jQuery since 1.2.6+. Setter and callback forms arrived in 1.8+. It wraps cross-browser reads of offsetHeight (content plus padding plus border) with optional margin via the true flag — no browser-specific quirks beyond jQuery itself.

jQuery 1.2.6+

jQuery .outerHeight()

Supported in jQuery 1.x, 2.x, and 3.x across all modern browsers and IE with supported jQuery builds. Native equivalent: element.offsetHeight — jQuery adds collection semantics, unitless Numbers, optional margin, setter support, and callback chaining.

100% With jQuery loaded
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
.outerHeight() Universal

Bottom line: Safe in any jQuery project. Use .outerHeight() when border belongs in the measurement; pass true when margin matters; use .height() for content-only or window/document reads.

Conclusion

The jQuery .outerHeight() method gets or sets element height including padding and border as a unitless pixel Number — the right dimension helper when the full border box matters for headers, stacked cards, and layout subtraction. Pass true to include vertical margin; it sits above .innerHeight() (padding only) and below nothing in the box model stack.

Remember the official demo: $( "p" ).first().outerHeight() reads the border box, and .outerHeight(true) adds margin. Use the setter .outerHeight(60) to target the full outer box, the callback form to shrink per click, and .outerHeight(true) when summing stacked elements — but never call .outerHeight() on window or document directly.

💡 Best Practices

✅ Do

  • Use .outerHeight() when border width must be included in the measurement
  • Pass true when summing stacked elements where margin gaps matter
  • Use $("#header").outerHeight() to subtract fixed headers from viewport height
  • Use the callback setter for shrink/grow patterns based on current outer height
  • Reach for .innerHeight() when border should be excluded from the count

❌ Don’t

  • Call .outerHeight() on $(window) or $(document)
  • Trust .outerHeight() on display:none elements — it may return 0
  • Assume .outerHeight() includes margin — pass true explicitly
  • Rely on per-cell .outerHeight() on border-collapse: collapse tables without testing
  • Forget that an empty jQuery set returns undefined from the getter

Key Takeaways

Knowledge Unlocked

Six things to remember about .outerHeight()

Full border box — margin optional.

6
Core concepts
= 02

Setter

1.8+

Write
brd 03

+ Border

Included

Box
T 04

true

+ Margin

Flag
el 05

Elements

Not window

Scope
hide 06

Hidden

Unreliable

Caveat

❓ Frequently Asked Questions

Calling .outerHeight() with no arguments returns the height of the first matched element including padding and border as a unitless Number — margin excluded. Pass true as .outerHeight(true) to include vertical margin in the measurement as well. The same Boolean applies to setters: .outerHeight(80) sets the outer box without margin; .outerHeight(80, true) accounts for margin when calculating the CSS height. The getter has been available since jQuery 1.2.6.
.height() returns content height only — padding, border, and margin excluded. .innerHeight() adds vertical padding on top of content. .outerHeight() adds padding and border (full border box). Pass true to .outerHeight(true) to add margin as well. All three return unitless Numbers for getters — pick the method that matches the CSS layer you are measuring. For raw CSS strings such as '80px' or 'auto', use .css('height') instead.
The getter .outerHeight([includeMargin]) has been available since jQuery 1.2.6. The setter .outerHeight(value [, includeMargin]) and the callback form .outerHeight(function(index, height)) were both added in jQuery 1.8. The callback receives the zero-based index and the element's current outer height; return a new Number to set each element independently — useful for shrink-on-click panels and staggered box layouts.
No — .outerHeight() is for elements only. Unlike .height(), which works on $(window) and $(document), .outerHeight() does not support window or document objects. For viewport height use $(window).height(); for full page scroll height use $(document).height(). Use .outerHeight() when you need the full border box of a DOM element — for example, subtracting a fixed header's outer height from the viewport to size a content area below it.
Yes — on table elements with border-collapse: collapse, border widths may be shared between adjacent cells and jQuery's .outerHeight() can report values that differ from what you expect when measuring individual cells or rows. Prefer measuring the table as a whole, temporarily set border-collapse: separate for measurement, or use getBoundingClientRect() when precise per-cell border math is critical. For typical block-level divs and cards, .outerHeight() behaves predictably.
Calling .outerHeight() on an empty jQuery set returns undefined — there is no first element to measure. On display:none or visibility:hidden elements, .outerHeight() is unreliable and may return 0 because the element is not rendered; temporarily show the element or clone it off-screen before measuring. Returned heights can be fractional (e.g. 86.5) on sub-pixel layouts or zoomed displays; use Math.round() when you need integers for layout or animation targets.
Did you know?

jQuery’s .outerHeight() getter has existed since version 1.2.6 — long before setters arrived in 1.8. It maps closely to the native offsetHeight property: content plus padding plus border, no margin unless you pass true. On a typical element with 4px border and 16px vertical padding, .outerHeight() reads roughly 24px taller than .innerHeight(). The horizontal mirror is .outerWidth() — same box-model rules, different axis. For viewport math, combine $(window).height() with element .outerHeight() on fixed headers, but never call .outerHeight() on the window object itself.

Next: .innerWidth()

Learn width including padding — the horizontal counterpart.

.innerWidth() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful