jQuery .innerHeight() Method

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

What You’ll Learn

The .innerHeight() method gets or sets the height of matched elements including padding as a unitless pixel Number — ideal when the padded inner box matters for scroll areas and layout math. This tutorial covers getter and setter overloads, comparisons with .height(), .outerHeight(), and .css("height"), callback setters since 1.8, and practical scroll-panel patterns.

01

Getter

.innerHeight() → Number

02

Setter

Since 1.8

03

+ Padding

Not border

04

vs height

Content only

05

Callback

Since 1.8

06

Since 1.2.6

Getter API

Introduction

After learning .height(), which measures the content box only, you often need a dimension that includes padding — especially for scrollable panels, cards with internal spacing, and comparisons with CSS clientHeight. jQuery’s .innerHeight() returns a plain number for the content area plus vertical padding, ready for math and .animate() without parsing "96px" strings.

Available since jQuery 1.2.6 as a getter, .innerHeight() gained setter and callback forms in jQuery 1.8. The getter reads the padded inner height of the first matched element; the setter adjusts CSS height so the inner box (content plus padding) matches your target. Unlike .height(), it does not work on $(window) or $(document) — use it on DOM elements only.

Understanding the .innerHeight() Method

Given a jQuery object, .innerHeight() either returns the current height of the first matched element — content plus vertical padding — as a unitless pixel Number (getter), or sets the CSS height on every matched element so the inner box equals your value (setter). Border and margin are excluded; only padding is added on top of content height.

Think of .innerHeight() as a ruler that extends through padding. .height() stops at the content edge; .outerHeight() continues through border (and optionally margin). Use .innerHeight() when scrollable areas or padded containers need precise pixel targets — for example, fitting a panel to the remaining viewport below a fixed header.

💡
Beginner Tip

On a box with padding: 12px and content height 56px: .height() returns 56, .innerHeight() returns 80 (56 + 12 + 12). For the full box including border, use .outerHeight().

📝 Syntax

jQuery .innerHeight() has three argument forms — one getter and two setters:

Get — no arguments (since 1.2.6)

jQuery
.innerHeight()  // -> Number
  • Returns the height of the first matched element including padding as a unitless pixel Number.
  • Border and margin are excluded — padding is included.
  • Not for $(window) or $(document) — elements only.
  • Returns undefined when the jQuery set is empty.

Set — Number (since 1.8)

jQuery
.innerHeight( value )  // -> jQuery
  • value — target inner height in pixels as a Number (e.g. 70).
  • jQuery adjusts the CSS height so content plus padding equals the value.
  • Returns the original jQuery object for chaining — e.g. .innerHeight(70).addClass("mod").

Set — callback function (since 1.8)

jQuery
.innerHeight( function( index, height ) {
  // return new inner height (Number)
} )
  • index — zero-based position of the element in the matched set.
  • height — current inner height of this element before the change.
  • Return a new inner 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

.innerHeight() 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( "innerHeight: " + p.innerHeight() + "px" );

⚡ Quick Reference

GoalCode
Read padded inner height (Number)$("div").innerHeight()
Set inner height in pixels$("div").innerHeight(100)
Shrink inner height per click$("div").innerHeight(function(i, h){ return h - 10; })
Content height only (no padding)$("div").height()
Include padding + border$("div").outerHeight()
CSS height as string$("div").css("height")
Viewport height (not innerHeight)$(window).height()
Fit scroll panel below header$("#panel").innerHeight($(window).height() - $("#header").outerHeight())

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

Four ways to read vertical dimensions — content box, padded inner box, full border box, and raw CSS strings.

.innerHeight()
+ pad

Get/set height including padding — returns unitless Number

.height()
content

Content height only — padding and border excluded; works on window/document

.outerHeight()
+ border

Includes padding and border; pass true to add margin

.css()
"80px"

General CSS getter/setter — height returns String with units or auto

Examples Gallery

Examples 1–2 follow the official jQuery API documentation. Examples 3–5 compare dimension methods, demonstrate callback setters, and build a viewport-fitted scroll panel. Use DevTools or the Try-it links to run each snippet.

📚 Getting Started

Official jQuery demos for reading and setting inner height.

Example 1 — Official Demo: Get First Paragraph Inner Height

Read the padded inner height of the first <p> and display it.

jQuery
var p = $( "p" ).first();
$( "#result" ).text( "innerHeight: " + p.innerHeight() + "px" );
Try It Yourself

How It Works

No-argument .innerHeight() returns a unitless pixel Number for the first element — content height plus vertical padding. Border width is not included; that is what .outerHeight() adds.

Example 2 — Official Demo: Set Inner Height on Click

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

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

How It Works

.innerHeight(70) sets the CSS height so the inner box (content plus padding) totals 70 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 viewport-fitted scroll areas.

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

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

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

How It Works

All three return unitless Numbers. .height() stops at content; .innerHeight() adds padding; .outerHeight() adds border. Pick the method that matches what you are measuring — scrollable client area often maps to .innerHeight().

Example 4 — Callback Setter: Shrink Inner Height by 10px

Each click reduces the panel’s inner height by 10 pixels, with a minimum of 40px.

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

How It Works

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

Example 5 — Viewport Scroll Panel: fitPanel() with .innerHeight()

Set the scroll panel’s inner height to fill the viewport below a fixed header, recalculating on resize.

jQuery
function fitPanel() {
  var headerH = $( "#header" ).outerHeight();
  var available = $( window ).height() - headerH;
  $( "#panel" ).innerHeight( available );
}
fitPanel();
$( window ).on( "resize", fitPanel );
Try It Yourself

How It Works

$(window).height() gives viewport height; $("#header").outerHeight() includes the header’s border. The remainder is passed to .innerHeight() so the panel’s padded inner box exactly fills the available space — a common admin-dashboard and split-layout pattern.

🚀 Common Use Cases

  • Scrollable panels$("#panel").innerHeight($(window).height() - headerH) to fill remaining viewport with a scroll area.
  • Padded card sizing — when CSS padding is fixed, .innerHeight() targets the visible inner box including that padding.
  • Dimension debugging — compare .height(), .innerHeight(), and .outerHeight() to trace box-model mismatches.
  • Shrink-on-click UI — callback setter .innerHeight(function(i, h){ return h - 10; }) for interactive panels.
  • Equal inner heights — read each card’s .innerHeight(), find the max, set all to match padded columns.
  • Animation targets — pair measured .innerHeight() with .animate() when padding must stay inside the animated box.

🧠 How .innerHeight() Reads and Writes Dimensions

1

Match elements

jQuery object holds DOM elements — not window or document.

Input
2

Detect mode

No args → getter. Number or function → setter on each element (1.8+).

Route
3

Measure or apply

Getter reads clientHeight (content + padding). Setter adjusts CSS height to hit the target inner 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 — border and margin excluded.
  • 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.
  • Values can be fractional (e.g. 82.5) on sub-pixel or zoomed displays.
  • Setter returns the original jQuery object — e.g. .innerHeight(70).addClass("mod").

Browser Support

.innerHeight() getter has been part of jQuery since 1.2.6+. Setter and callback forms arrived in 1.8+. It wraps cross-browser reads of clientHeight (content plus padding) with no browser-specific quirks beyond jQuery itself.

jQuery 1.2.6+

jQuery .innerHeight()

Supported in jQuery 1.x, 2.x, and 3.x across all modern browsers and IE with supported jQuery builds. Native equivalent: element.clientHeight — jQuery adds collection semantics, unitless Numbers, 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
.innerHeight() Universal

Bottom line: Safe in any jQuery project. Use .innerHeight() when padding belongs in the measurement; use .height() for content-only or window/document reads.

Conclusion

The jQuery .innerHeight() method gets or sets element height including padding as a unitless pixel Number — the right dimension helper when the padded inner box matters for scroll areas, cards, and layout math. It sits between .height() (content only) and .outerHeight() (padding plus border).

Remember the official demo: $( "p" ).first().innerHeight() reads padded inner height, and the setter .innerHeight(70) targets the full inner box. Use the callback form to shrink or grow per element, and pair .innerHeight() with $(window).height() for viewport-fitted scroll panels — but never call .innerHeight() on window or document directly.

💡 Best Practices

✅ Do

  • Use .innerHeight() when padding must be included in the measurement
  • Use .innerHeight(value) to size scroll panels to a pixel target
  • Use the callback setter for shrink/grow patterns based on current inner height
  • Combine $(window).height() with .innerHeight() on elements for viewport layouts
  • Reach for .outerHeight() when border width also affects layout

❌ Don’t

  • Call .innerHeight() on $(window) or $(document)
  • Trust .innerHeight() on display:none elements — it may return 0
  • Assume .innerHeight() includes border — use .outerHeight() instead
  • Expect the getter to read all matched elements — only the first
  • Forget that an empty jQuery set returns undefined from the getter

Key Takeaways

Knowledge Unlocked

Six things to remember about .innerHeight()

Padded inner box — ready for math.

6
Core concepts
= 02

Setter

1.8+

Write
pad 03

+ Padding

Included

Box
fn 04

Callback

1.8+

Index
el 05

Elements

Not window

Scope
hide 06

Hidden

Unreliable

Caveat

❓ Frequently Asked Questions

Calling .innerHeight() with no arguments is the getter — it returns the current height of the first matched element as a unitless Number (pixels), including padding but excluding border and margin. Calling .innerHeight(value) or .innerHeight(function) is the setter — it sets the CSS height on every matched element so that the inner height (content plus padding) equals the value you pass, and returns the original jQuery object for chaining. The getter has been available since jQuery 1.2.6; setters arrived in 1.8.
Yes to padding — .innerHeight() measures the content box plus vertical padding, equivalent to clientHeight without scrollbar width. It does not include border or margin. For the full box including border, use .outerHeight(); pass true to .outerHeight(true) to add margin as well. For content height only (no padding), use .height().
.height() returns content height only — padding and border excluded. .innerHeight() adds padding on top of content. .outerHeight() adds padding and border (and optionally margin). All three return unitless Numbers for getters. .css('height') is a general CSS getter that returns a string such as '80px' or 'auto' — use it when you need literal CSS values or percentage heights, not for quick pixel math.
No — .innerHeight() is for elements only. Unlike .height(), which works on $(window) and $(document), .innerHeight() does not support window or document objects. For viewport height use $(window).height(); for full page scroll height use $(document).height(). Use .innerHeight() when you need the padded inner box of a DOM element such as a scrollable panel or card.
The getter .innerHeight() has been available since jQuery 1.2.6. The setter .innerHeight(value) and the callback form .innerHeight(function(index, height)) were both added in jQuery 1.8. The callback receives the zero-based index and the element's current inner height; return a new Number to set each element's inner height independently — useful for staggered panels and shrink-on-click interactions.
Calling .innerHeight() on an empty jQuery set returns undefined — there is no first element to measure. On display:none or visibility:hidden elements, .innerHeight() 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. 82.5) on sub-pixel layouts or zoomed displays; use Math.round() when you need integers for layout.
Did you know?

jQuery’s .innerHeight() getter has existed since version 1.2.6 — long before setters arrived in 1.8. It maps closely to the native clientHeight property: content plus padding, no border. On a typical element with 16px vertical padding, .innerHeight() reads roughly 32px taller than .height(). The callback setter mirrors .height() and .width() — return a different inner height per index for shrink panels and staggered layouts. For viewport math, combine $(window).height() with element .innerHeight(), but never call .innerHeight() on the window object itself.

Next: .outerHeight()

Learn height including padding, border, and optional margin.

.outerHeight() 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