Latest web development tutorials
 

HTML DOM clientTop Propery

< Element Object

Example

Get the width of a <div> element's top and left border:

var elmnt = document.getElementById("myDIV");
var txt = "Border top width: " + elmnt.clientTop + "px<br>";
txt += "Border left width: " + elmnt.clientLeft + "px";

The result of txt will be:

Border top width: 15px
Border left width: 10px
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

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

This property does not include the element's top padding or top margin.

Tip: You can also use the style.borderTopWidth property to return the width of an element's top border.

Tip: To return the width of the left border of an element, use the clientLeft property.

This property is read-only.


Browser Support

Property
clientTop Yes Yes Yes Yes Yes

Syntax

element.clientTop

Technical Details

Return Value: A Number, representing the width of an element's top border, in pixels

< Element Object