Element.clientTop is a read-only instance property that returns the width of an element’s top border in pixels. Learn how it matches border-top-width, how it relates to offsetTop, and how it pairs with clientLeft—with five examples and try-it labs.
01
Kind
Instance property
02
Access
Read-only
03
Type
Integer (px)
04
Measures
Top border
05
Equals
border-top-width
06
Status
Baseline widely
Fundamentals
Introduction
The client area is the padded content box inside the borders. clientTop tells you how thick the top border is—the gap from the outer top of the border box to where the padding/content starts.
MDN puts it simply: clientTop is always equal to the computed border-top-width, rounded to an integer. If that width is zero, so is clientTop.
JavaScript
const el = document.getElementById("contained");
console.log(el.clientTop); // e.g. 24 for border-top: 24px
💡
Beginner tip
Remember: clientTop = top border width. It is not margin and not padding.
Concept
Understanding the Property
MDN: the clientTop read-only property of the Element interface returns the width of the top border of an element in pixels.
All that lies between offsetTop and the start of the client area is the element’s top border. offsetTop marks the top of the border (not the margin), while the client area begins immediately below the border (including padding). That distance is clientTop.
Read-only — change CSS borders, then read again.
Integer pixels — top border thickness.
Matches CSS — equals border-top-width (rounded).
Baseline — widely available since July 2015 (MDN).
Foundation
📝 Syntax
JavaScript
clientTop
Value
An integer: the top border width in pixels.
Item
Detail
Type
number (integer pixels)
Access
Read-only
Includes
Top border width
Equals
border-top-width (rounded to integer)
⚠️
Zero border
If the computed border-top-width is 0, then clientTop is also 0. Prefer a block-level box when you want a clear measurement for teaching or layout math.
Pattern
📋 MDN Border Example Shape
MDN uses a box with a 24px black top border. The white client area starts after that border, so clientTop is 24:
Element.clientTop 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.clientTop
Read-only integer — width of the top border in pixels (equals border-top-width).
BaselineWidely available
Google ChromeSupported
Yes
Microsoft EdgeSupported
Yes
Mozilla FirefoxSupported
Yes
Apple SafariSupported
Yes
OperaSupported
Yes
Internet ExplorerSupported
Yes
clientTopBaseline
Bottom line: Use clientTop for top border thickness. It matches border-top-width (rounded). Pair with clientLeft for left border width.
Wrap Up
Conclusion
clientTop is a simple border measurement: the top border width in pixels. It matches border-top-width, sits between offsetTop and the client area, and pairs cleanly with clientLeft.
Read-only top border width in pixels—matches border-top-width.
5
Core concepts
📄01
Get only
on Element
Kind
📝02
Integer px
top border
Type
🔍03
Box offsets
layout math
Use
✅04
Baseline
widely available
Status
🎯05
CSS match
border-top-width
Tip
❓ Frequently Asked Questions
It returns the width of the element's top border in pixels. MDN notes it is always equal to border-top-width, rounded to an integer.
No. MDN marks Element.clientTop as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
No. It is a read-only instance property. Change the border with CSS, then read clientTop again.
offsetTop points at the top of the border box (not the margin). The client area starts just below the border, so the gap between them is the top border—clientTop.
When the computed border-top-width is zero. Prefer measuring on block-level boxes when teaching the box model.
clientTop is the top border width; clientLeft is the left border width. Together they describe the client area's border offset.
Did you know?
In MDN’s demo, the yellow area is margin and the white area is the client box. clientTop is the black top border between them—24px in that example.