jQuery .innerHeight() Method

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

What Is .innerHeight()?

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

Remember
$("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
NeedUse
Content only$el.height()
Content + padding$el.innerHeight()
Include border (and optional margin)$el.outerHeight()

How to Use .innerHeight()

Measure or set the padded inner box — never on window or document.

  1. Select a DOM element (not window or document).
  2. Call .innerHeight() with no args to read content + padding as a Number.
  3. Pass a Number or CSS string to set that inner height on every match.
  4. Use the callback form when each element needs a different value (jQuery 1.8+).
PieceRequired?Role
jQuery selectionYesElement(s) only — not window/document
value / functionSetter only (1.8+)New inner height (Number, string, or per-element fn)
Return—Getter → Number (or undefined if empty); setter → jQuery

Pseudocode

Pseudocode
function innerHeight(selection, value):
    if selection is empty:
        return undefined

    if value is missing:
        el = first matched element
        return contentHeight(el) + verticalPadding(el)

    for each el in selection:
        if value is a function:
            newH = value(index, currentInnerHeight)
        else:
            newH = value
        set CSS height so content + padding = newH
    return selection

Cheat Sheet

Keep these facts handy while measuring the padded box.

TopicDetail
Syntax.innerHeight() / .innerHeight(value) / .innerHeight(fn)
SinceGetter 1.2.6; setter & callback 1.8
Getter returnsUnitless pixel Number (may be fractional)
IncludesContent + padding
ExcludesBorder and margin
Window / documentNot supported — use .height()
Empty setundefined (jQuery 3+)

Live Preview

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

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

Result
$("#box").innerHeight()
→ 76

/* content 60 + padding 8+8 */

jQuery Examples

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

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.
  4. Border ignored. A border does not change this value (use .outerHeight() for that).

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.
  4. Pick the edge. Match the method to the box edge your layout needs.

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.
  4. Verify. Call .innerHeight() again to confirm the new value.

Example 4 — Callback Setter (Since 1.8)

Shrink each panel’s inner height from its current value.

jQuery
$(".panel").innerHeight(function (index, current) {
  return current - 8;
});

$(".panel").each(function (i) {
  console.log("panel " + i + ": " + $(this).innerHeight() + "px");
});
Try It Yourself

How It Works

  1. Callback. jQuery calls your function once per matched element.
  2. Args. First is the index; second is the current inner height.
  3. Return. Return the new inner height for that element.
  4. Pattern. Handy for staggered clicks or shrinking a set of panels evenly.

Edge Cases & Pitfalls

Check these before trusting .innerHeight() 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.

empty

Empty set → undefined

No first element means no Number. Guard selections before doing math.

fraction

Values may be fractional

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

Browser Support

.innerHeight() 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+

.innerHeight()

Dimension API for content height plus padding — 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
.innerHeight() Excellent

Bottom line: Use .innerHeight() when padding must count. Switch to .height() for content only, or .outerHeight() when border (or margin) matters.

Performance Notes

ApproachCostBest for
.innerHeight()Layout readPadded-box math
.height()Layout readContent-only math
Repeated reads in a loopCan thrash layoutCache the Number first

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

Key Takeaways

  • Role: get/set height including padding as a unitless Number.
  • Box ladder: height → innerHeight → outerHeight.
  • Scope: elements only — use .height() for window/document.
  • Safety: measure visible elements; expect fractional pixels.

One line: .innerHeight() is content + padding — get for padded-box math, set since 1.8, and leave window/document to .height().

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

Learn how to include padding and 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.

8 people found this page helpful