HTML DOM Element clientTop Attribute
- Previous page clientLeft
- Next page clientWidth
- Go up one level HTML DOM Elements Object
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:
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";
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 |
- Previous page clientLeft
- Next page clientWidth
- Go up one level HTML DOM Elements Object