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
Fundamentals
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.
Concept
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).
Foundation
📝 Syntax
JavaScript
clientHeight
Value
An integer: the element’s inner height in pixels.
Item
Detail
Type
number (integer pixels)
Access
Read-only
Includes
Content height + padding
Excludes
Border, 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.
Pattern
📋 Measuring a Box
Give an element a fixed height and padding, then read clientHeight:
Element.clientHeight is Baseline Widely available (MDN: across browsers since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.
Bottom line: Use clientHeight for the visible client area. Compare with offsetHeight (borders) and scrollHeight (overflow). On the root element it reports viewport height.
Wrap Up
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.
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
Summary
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
📄01
Get only
on Element
Kind
📝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.