- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the differences between clientHeight() and offsetHeight() in javascript?
You can use 2 properties, clientHeight and offsetHeight to get the height of the div.
clientHeight includes padding of the div.
offsetHeight includes padding, scrollBar, and borders of the div.
Example
For example, if you have the following HTML −
<div id="myDiv" height="400px"></div>
You can get the height using −
const height = document.querySelector('#myDiv').offsetHeight console.log(height)
Output
This will give the output −
400
Advertisements