HTML DOM clientTop Property

元素对象参考手册Element Object

Example

Get the width of the top and left borders of a div element:

var elmnt = document.getElementById("myDIV"); var txt = "Top border width:" + elmnt.clientTop + "px<br>"; txt += "Left border width:" + elmnt.clientLeft + "px";

Try it Yourself »

Definition and Usage

clientTop represents the width of the top border of an element, in pixels.

clientTop does not include the left margin and left padding.

Tip:You can usestyle.borderTopWidth the property to get the width of the element's top border.

Tip:To return the width of the element's left border, you can useclientLeft property.

clientLeft is read-only.


Browser Support

Property
clientTop Yes Yes Yes Yes Yes

Syntax

element.clientTop 

Technical Details

Return Value: Returns an integer representing the width of the element's top border.


元素对象参考手册Element Object

Other Extensions