jQuery .outerHeight() Method

Beginner
6 min read
Updated: Oct 2026
4 examples
Live preview

What Is .outerHeight()?

.outerHeight() gets or sets the height of matched elements including padding and border (getter since 1.2.6; setter since 1.8). Pass true to include margin. The getter returns a unitless pixel Number.

Remember
$("div").outerHeight()           // content + padding + border
$("div").outerHeight(true)       // also include margin
$("div").outerHeight(100)        // set outer height (1.8+)
$("div").outerHeight(100, true)  // set accounting for margin

.height()         → content only
.innerHeight()    → content + padding
.outerHeight()    → content + padding + border
.outerHeight(true)→ + margin
NeedUse
Content only$el.height()
Content + padding$el.innerHeight()
Border box (+ optional margin)$el.outerHeight() / $el.outerHeight(true)

How to Use .outerHeight()

Measure or set the border box — never on window or document.

  1. Select a DOM element (not window or document).
  2. Call .outerHeight() to read content + padding + border.
  3. Pass true when vertical margin must count too.
  4. Pass a Number/string (or callback) to set outer height since jQuery 1.8.
PieceRequired?Role
jQuery selectionYesElement(s) only — not window/document
includeMarginOptionaltrue adds vertical margin
value / functionSetter only (1.8+)New outer height (Number, string, or per-element fn)

Pseudocode

Pseudocode
function outerHeight(selection, valueOrMargin, includeMargin):
    if selection is empty:
        return undefined

    if valueOrMargin is missing or is a Boolean:
        el = first matched element
        h = contentHeight + padding + border
        if valueOrMargin === true: h += margin
        return h

    for each el in selection:
        newH = valueOrMargin is function
            ? valueOrMargin(index, currentOuterHeight)
            : valueOrMargin
        set CSS height so outer box = newH
    return selection

Cheat Sheet

Keep these facts handy while measuring the border box.

TopicDetail
Syntax.outerHeight([true]) / .outerHeight(value[, true]) / .outerHeight(fn)
SinceGetter 1.2.6; setter & callback 1.8
Getter returnsUnitless pixel Number (may be fractional)
IncludesContent + padding + border
trueAlso include margin
Window / documentNot supported — use .height()
Empty setundefined (jQuery 3+)

Live Preview

Pick an action against the sample box and see what .outerHeight() returns or sets.

Browser demo of .outerHeight() — same idea as the examples below.

Result
$("#box").outerHeight()
→ 80

/* content + padding + border */

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — Get Outer Height of a Paragraph

Official style: read content + padding + border as a Number.

jQuery
var p = $("p").first();

console.log("outerHeight: " + p.outerHeight() + "px");
Try It Yourself

How It Works

  1. Select. Grab the first paragraph with $("p").first().
  2. Measure. .outerHeight() adds padding and border to content height.
  3. Type. The result is a Number — append "px" only when printing.
  4. Margin ignored. Vertical margin is not included unless you pass true.

Example 2 — Include Margin with true

Compare the border box with the margin box.

jQuery
var p = $("p").first();

console.log("outerHeight:       " + p.outerHeight());
console.log("outerHeight(true): " + p.outerHeight(true));
Try It Yourself

How It Works

  1. Default. .outerHeight() stops at the border edge.
  2. With true. .outerHeight(true) adds top and bottom margin.
  3. Use case. Stack height math — how much total space a card occupies.
  4. Rule. Prefer true when spacing between siblings matters.

Example 3 — .height() vs .innerHeight() vs .outerHeight()

See how padding and border change each reading.

jQuery
var $box = $("#box");

console.log("height:      " + $box.height());
console.log("innerHeight: " + $box.innerHeight());
console.log("outerHeight: " + $box.outerHeight());
Try It Yourself

How It Works

  1. Content. .height() stops at the content box.
  2. Padding. .innerHeight() adds top and bottom padding.
  3. Border. .outerHeight() also includes the border width.
  4. Pick the edge. Match the method to the box edge your layout needs.

Example 4 — Set Outer Height with a Number

Pass a Number so the border box equals that target (since 1.8).

jQuery
$("#box").outerHeight(90);

console.log($("#box").outerHeight());  // 90
Try It Yourself

How It Works

  1. Setter. .outerHeight(90) adjusts CSS height so the border box is 90px tall.
  2. Pixels. A bare Number means pixels; strings can use units like "50%".
  3. Margin flag. Use .outerHeight(90, true) when the target should include margin.
  4. Verify. Call .outerHeight() again to confirm the new value.

Edge Cases & Pitfalls

Check these before trusting .outerHeight() in layout code.

scope

Not for window or document

Use .height() for viewport and page measurements.

hidden

Hidden elements can report 0

Measure while the element is visible. Temporary show/re-hide tricks are slow and may go away.

table

border-collapse: collapse can surprise

Shared borders on collapsed tables may make per-cell .outerHeight() look wrong. Prefer measuring the table as a whole.

fraction

Values may be fractional

Sub-pixel layouts can return numbers like 80.5. Round only when your UI needs integers.

Browser Support

.outerHeight() getter has shipped since jQuery 1.2.6; the setter and callback forms arrived in jQuery 1.8. Works in all modern browsers with jQuery loaded.

✓ jQuery 1.2.6+

.outerHeight()

Dimension API for content + padding + border — pass true for margin. Getter returns a unitless Number; setter accepts Number, string, or function (1.8+).

100% Browser support
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() Excellent

Bottom line: Use .outerHeight() for the border box. Pass true for margin. Switch to .height() / .innerHeight() for smaller box edges.

Performance Notes

ApproachCostBest for
.outerHeight()Layout readBorder-box math
.outerHeight(true)Layout readSpace including margin
Repeated reads in a loopCan thrash layoutCache the Number first

Dimension getters force layout. Read once, reuse the Number, and avoid calling .outerHeight() inside tight loops unless needed.

Key Takeaways

  • Role: get/set height including padding and border.
  • Margin: pass true when spacing must count.
  • Box ladder: height → innerHeight → outerHeight.
  • Scope: elements only — use .height() for window/document.

One line: .outerHeight() is the border box — pass true for margin, set since 1.8, and leave window/document to .height().

Frequently Asked Questions

.outerHeight() with no arguments returns the height of the first matched element including padding and border as a unitless pixel Number. Pass true to include margin. .outerHeight(value) or .outerHeight(function) sets that outer height on every matched element (since 1.8).
.height() is content only. .innerHeight() adds padding. .outerHeight() adds padding and border. .outerHeight(true) also includes margin. All getters return unitless Numbers.
No. The API is for elements only. Use $(window).height() for the viewport and $(document).height() for the full page.
The getter has been available since jQuery 1.2.6. The setter .outerHeight(value) and the callback form arrived in jQuery 1.8.
Calling .outerHeight() on an empty jQuery set returns undefined (null before jQuery 3.0). Always check that your selection matched something before using the Number.
No. Values can be wrong (often 0) when the element or a parent is hidden. Measure while visible. Fractional pixels are possible — do not assume an integer.

Next: .innerWidth()

Learn the horizontal twin for width including padding.

.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.

8 people found this page helpful