In many situations in web design or development, you may need to get the width of div element for some reasons. Here in this post, I am just going to show you simple code snippet which can be used to get the width of an HTML div element.
If you don’t want to include border width then go with the below code:
The above code will not include the border and take the width of a div element by excluding the border width.
Get the width of HTML div element using jQuery
Below is given some more methods:
- innerWidth() – Returns the width of an element (includes padding).
- outerWidth() – Returns the width of an element (includes padding and border).