HTML DOM Element clientTop
Example
Get the width of myDIV's top and left border:
const element = document.getElementById("myDIV");
let text = "clientTop: " + element.clientTop + "px<br>";
text += "clientLeft: " + element.clientLeft + "px";
Try it Yourself »
Definition and Usage
The clientTop property returns the width of the top border of an element, in pixels.
The clientTop property does not include the element's top padding or top margin.
The clientTop property is read-only.
Note
The style.borderTopWidth Property also returns the width of an element's top border.
Tutorial:
See Also:
Syntax
element.clientTop
Return Value
| Type | Description |
| Number | The width of an element's top border, in pixels. |
Browser Support
element.clientTop is supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera | IE |
| Yes | Yes | Yes | Yes | Yes | Yes |