S
S
Scalletta2018-08-21 17:41:06
JavaScript
Scalletta, 2018-08-21 17:41:06

What is the difference between .height and .offsetHeight in JavaScript?

What is the difference between
clientHeight includes padding.
offsetHeight includes padding, scrollBar and borders.
.style.height block height.
I use .style.height for the block - it returns emptiness, and the parent has everything, the child has emptiness (even with a fixed height).
I write offsetHeight - all the rules.
Why is that? and what's the difference?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Egorov, 2018-08-21
@Scalletta

document.element.style.heightto specify the height, this property cannot be read.
Can be done like this ->

getComputedStyle(document.element).height //Вернет высоту
// или так
document.element.offsetHeight

Here are more details ->
https://learn.javascript.ru/styles-and-classes
https://learn.javascript.ru/metrics

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question