JavaScript Element clientHeight Property

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline
Instance property

What You’ll Learn

Element.clientHeight is a read-only instance property that returns an element’s inner height in pixels. Learn what padding and scrollbars do to the value, how the root element reports viewport height, and how it compares to offsetHeight / scrollHeight—with five examples and try-it labs.

01

Kind

Instance property

02

Access

Read-only

03

Type

Integer (px)

04

Includes

Padding

05

Excludes

Border · margin

06

Status

Baseline widely

Introduction

Layout work often needs the visible content box height: how tall is the area inside the borders? That is what clientHeight answers.

It includes padding, but leaves out borders, margins, and any horizontal scrollbar. For elements with no CSS/inline layout box, the value is 0.

JavaScript
const box = document.getElementById("box");
console.log(box.clientHeight); // inner height in pixels
💡
Beginner tip

Think: client = the client area (content + padding). Borders sit outside that area and do not count.

Understanding the Property

MDN: the clientHeight read-only property of the Element interface is zero for elements with no CSS or inline layout boxes; otherwise, it is the inner height of an element in pixels. It includes padding but excludes borders, margins, and horizontal scrollbars (if present).

  • Read-only — change CSS/layout, then read again.
  • Integer pixels — rounded layout measurement.
  • Formula — CSS height + padding − horizontal scrollbar height.
  • Baseline — widely available since July 2015 (MDN).

📝 Syntax

JavaScript
clientHeight

Value

An integer: the element’s inner height in pixels.

ItemDetail
Typenumber (integer pixels)
AccessRead-only
IncludesContent height + padding
ExcludesBorder, margin, horizontal scrollbar
⚠️
Root / viewport

On document.documentElement (the <html> root), or on <body> in quirks mode, clientHeight returns the viewport height excluding any scrollbar.

📋 Measuring a Box

Give an element a fixed height and padding, then read clientHeight:

JavaScript
<div id="box" style="height:100px;padding:10px;border:5px solid #333;">
  Hello
</div>
JavaScript
const box = document.getElementById("box");
console.log(box.clientHeight);
// height 100 + padding-top 10 + padding-bottom 10 = 120
// border is NOT included

Related learning: clientWidth, offsetHeight, scrollHeight, and getBoundingClientRect().

⚡ Quick Reference

GoalCode / note
Read heightel.clientHeight
Viewport heightdocument.documentElement.clientHeight
With bordersel.offsetHeight
Scrollable contentel.scrollHeight
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.clientHeight.

Kind
get only

Instance

Type
integer

Pixels

Includes
padding

Not border

Baseline
widely

Jul 2015+

Examples Gallery

Examples follow MDN Element: clientHeight. Labs use a styled box so the pixel measurements are easy to predict.

📚 Getting Started

Read the inner height and see how padding contributes.

Example 1 — Read clientHeight

Log the client height of a fixed-size box.

JavaScript
const box = document.getElementById("box");
console.log(box.clientHeight);
Try It Yourself

How It Works

With height: 100px and no padding, clientHeight is typically 100. Borders do not change this value.

Example 2 — Padding Is Included

Add vertical padding and watch the measurement grow.

JavaScript
const box = document.getElementById("box");
// style: height:100px; padding:10px; border:5px solid
console.log(box.clientHeight); // 120 (100 + 10 + 10)
Try It Yourself

How It Works

Top and bottom padding add to the client height. The 5px border is ignored by clientHeight (but not by offsetHeight).

📈 Compare Sizes, Viewport & Snapshot

Relate client, offset, and scroll heights; then measure the viewport.

Example 3 — vs offsetHeight and scrollHeight

Compare three common height measurements on one element.

JavaScript
const box = document.getElementById("box");
console.log({
  clientHeight: box.clientHeight,
  offsetHeight: box.offsetHeight,
  scrollHeight: box.scrollHeight
});
Try It Yourself

How It Works

offsetHeight often adds borders (here +10). scrollHeight grows when content overflows the visible client area.

Example 4 — Viewport Height

Read the visible viewport height from the document element.

JavaScript
console.log(document.documentElement.clientHeight);
Try It Yourself

How It Works

This is a common way to get layout viewport height without including the scrollbar thickness. Exact numbers depend on the window size.

Example 5 — Support Snapshot

Feature-detect and remember what the value includes.

JavaScript
console.log({
  supported: "clientHeight" in Element.prototype,
  includes: "content height + padding",
  tip: "Use offsetHeight for borders; scrollHeight for overflow content",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Pick the measurement that matches your layout question: inner area, border box, or scrollable content.

🚀 Common Use Cases

  • Measuring the visible height of panels, cards, and containers.
  • Detecting whether content overflows (scrollHeight > clientHeight).
  • Sizing overlays or sticky footers against the viewport.
  • Responsive logic that depends on available client area.
  • Debugging layout differences between padding and borders.

🔧 How It Works

1

Browser lays out the box

Height, padding, border, and scrollbars are computed.

Layout
2

Client area is measured

Content height plus vertical padding.

Client
3

Borders and margins stay out

Horizontal scrollbar height is subtracted if present.

Exclude
4

You get an integer

Use it for layout math, overflow checks, and viewport sizing.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available).
  • Read-only — change styles/layout to change the value.
  • Returns 0 when the element has no CSS or inline layout box.
  • Related: className, clientLeft, EventTarget, JavaScript hub.

Browser Support

Element.clientHeight is Baseline Widely available (MDN: across browsers since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline Widely available

Element.clientHeight

Read-only integer — inner height in pixels (includes padding, excludes border/margin).

Baseline Widely available
Google Chrome Supported
Yes
Microsoft Edge Supported
Yes
Mozilla Firefox Supported
Yes
Apple Safari Supported
Yes
Opera Supported
Yes
Internet Explorer Supported
Yes
clientHeight Baseline

Bottom line: Use clientHeight for the visible client area. Compare with offsetHeight (borders) and scrollHeight (overflow). On the root element it reports viewport height.

Conclusion

clientHeight is the go-to measurement for an element’s inner height. Include padding, skip borders and margins, and use the root element when you need viewport height.

Continue with clientLeft, className, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use it for visible content-area height
  • Compare with scrollHeight to detect overflow
  • Use document.documentElement.clientHeight for viewport
  • Re-read after layout or resize changes
  • Pair with clientWidth for 2D measurements

❌ Don’t

  • Expect borders or margins to be included
  • Assign to clientHeight (read-only)
  • Confuse it with CSS height alone when padding exists
  • Assume non-layout elements return a useful size
  • Skip reflow timing when measuring right after DOM inserts

Key Takeaways

Knowledge Unlocked

Five things to remember about clientHeight

Read-only inner height in pixels—padding in, border and margin out.

5
Core concepts
📝 02

Integer px

inner height

Type
🔍 03

Layout math

panels & overflow

Use
04

Baseline

widely available

Status
🎯 05

Padding in

border out

Tip

❓ Frequently Asked Questions

It returns the element's inner height in pixels, including padding but excluding borders, margins, and horizontal scrollbars.
No. MDN marks Element.clientHeight as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
No. It is a read-only instance property. Change layout with CSS or style APIs, then read clientHeight again.
Roughly CSS height + CSS padding − height of a horizontal scrollbar if one is present.
On the root <html> element (or <body> in quirks mode), clientHeight returns the viewport height excluding any scrollbar.
offsetHeight includes borders (and often scrollbars). scrollHeight is the full scrollable content height, which can be larger than the visible client area.
Did you know?

A classic overflow check is el.scrollHeight > el.clientHeight—true when content is taller than the visible client area.

Next: clientLeft

Learn how to read an element’s left border width in pixels.

clientLeft →

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.

5 people found this page helpful