- 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.
- CSS | Height and Width
- jQuery | width()
- CSS | max-width 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.