The width of the top border of an element in pixels. It is a read-only, integer property of element.
As it happens, all that lies between the two locations (
offsetTop and client area top) is the element's border. This is because the
offsetTop indicates the location of the top of the border (not the margin) while the client area starts immediately below the border, (client area includes padding.) Therefore, the clientTop value will always equal the integer portion of the
.getComputedStyle() value for "border-top-width". (Actually might be Math.round(parseFloat()).) For example, if the computed "border-top-width" is zero, then
clientTop is also zero.
Note: This property will round the value to an integer. If you need a fractional value, use
var top = element.clientTop;
In the following illustration, the client area is show in white. (The segments labeled "Top", "Right", etc. have no significance regarding the client area.) The clientTop value is the distance from where the margin (yellow) area ends and the padding and content areas (white) begin.
clientTop was first introduced in the MS IE DHTML object model.
|CSS Object Model (CSSOM) View Module
The definition of 'clientTop' in that specification.
|Chrome Full support 43||Edge Full support 12||Firefox Full support 1||IE Full support 6||Opera Full support 8||Safari Full support 6||WebView Android Full support 43||Chrome Android Full support 43||Firefox Android Full support 4||Opera Android Full support 10.1||Safari iOS Full support 6||Samsung Internet Android Full support 4.0|
- Full support
- Full support