HTML DOM Element clientTop Attribute

Definition and Usage

clientTop The attribute returns the width of the top border of the element, in pixels.

clientTop The attribute does not include the top padding or margin of the element.

clientTop The attribute is read-only.

Note:style.borderTopWidth attributeAlso returns the width of the top border of the element.

See also:CSS Box Model Tutorial

See also:

clientLeft attribute

clientWidth attribute

clientHeight attribute

offsetLeft attribute

offsetTop attribute

Example

Get the top and left border widths of myDIV:

const element = document.getElementById("myDIV");
let text = "clientTop: " + element.clientTop + "px<br>";
text += "clientLeft: " + element.clientLeft + "px";

Try it yourself

Syntax

element.clientTop

Return value

Type Description
Number The width of the top border of the element, in pixels.

Browser support

All browsers support element.clientTop:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support