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 »

Description

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.


Syntax

element.clientTop

Return Value

Type Description
NumberThe 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

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.