jQuery .outerHeight() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
CSS

Definition

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

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("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
CallWhat it does
.outerHeight()Learn jQuery .outerHeight(): get or set height including padding and border, optional outerHeight(true) for margin, compare with .height() and .innerHeight(), examples, pitfalls, and FAQs.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Select a DOM element (not window or document).
Step 2Call .outerHeight() to read content + padding + border.
Step 3Pass true when vertical margin must count too.

Return Value

Return ValueDescription
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

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.

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.

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.

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() Method — Width Including Padding

Learn the horizontal twin for width including padding.

.innerWidth() Method — Width Including Padding tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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