- Return Value:
- Returns the corresponding element’s layout pixel width.
The following program will illustrate the solution using offsetWidth:
The following program will illustrate the solution using clientWidth:
Note: clientWidth returns the inner width which includes padding but excludes borders and scroll bars whereas offsetWidth returns the outer width which includes padding and borders.
- How to overlay one div over another div using CSS
- How to copy the content of a div into another div using jQuery ?
- Creating Responsive Grid Vanilla using HTML,CSS and Bootstrap
- How to center a div within another div?
- How to clear all div's content inside a parent div ?
- How to animate div width and height on mouse hover using jQuery ?
- How to dynamically get the content width of a div using AngularJS ?
- How to set div width to fit content using CSS ?
- How to make div width expand with its content using CSS ?
- How to dynamically set the height and width of a div element using jQuery ?
- Fluid width with equally spaced div using CSS
- Creating Navbar | Vanilla HTML CSS Vs Bootstrap
- HTML width/height Attribute vs CSS width/height Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.