jQuery .innerHeight() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
CSS

Definition

.innerHeight() gets or sets the height of matched elements including padding, but not border or margin (getter since 1.2.6; setter since 1.8). The getter returns a unitless pixel Number.

Syntax

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

jQuery
$("div").innerHeight()        // Number → content + padding
$("div").innerHeight(100)     // set inner height to 100px
$("div").innerHeight(fn)      // per-element setter (1.8+)

.height()       → content only
.innerHeight()  → content + padding
.outerHeight()  → content + padding + border
CallWhat it does
.innerHeight()Learn jQuery .innerHeight(): get or set height including padding as a unitless pixel Number, compare with .height() and .outerHeight(), callback setter since 1.8, 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 .innerHeight() with no args to read content + padding as a Number.
Step 3Pass a Number or CSS string to set that inner height on every match.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

Example 1 — Get Inner Height of a Paragraph

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

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

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

How It Works

  1. Select. Grab the first paragraph with $("p").first().
  2. Measure. .innerHeight() adds vertical padding to content height.
  3. Type. The result is a Number — append "px" only when printing.

Example 2 — .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.

Example 3 — Set Inner Height with a Number

Pass a Number so content + padding equals that target (since 1.8).

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

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

How It Works

  1. Setter. .innerHeight(90) adjusts CSS height so the padded box is 90px tall.
  2. Pixels. A bare Number means pixels; strings can use units like "50%".
  3. Chain. The setter returns the jQuery object for further calls.

Frequently Asked Questions

.innerHeight() with no arguments returns the height of the first matched element including padding (not border or margin) as a unitless pixel Number. .innerHeight(value) or .innerHeight(function) sets that inner height on every matched element and returns the jQuery object for chaining.
.height() is content only. .innerHeight() adds padding. .outerHeight() adds padding and border (pass true to include 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 .innerHeight(value) and the callback form arrived in jQuery 1.8.
Calling .innerHeight() 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: .outerHeight() Method — Height Including Border

Learn how to include padding and border (and optional margin).

.outerHeight() Method — Height Including Border 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