HTML | DOM clientWidth Property
The DOM clientWidth Property is used to return the viewable width of a specific element including padding but excluding the measurement of margin, border and scrollbar width. This property only returns the actual width of an element that is viewable or visible to the user. It is a read-only property.
Syntax:
element.clientWidth
Return Value: It returns a Numeric value which represent the viewable width of an element.
Example:
<!DOCTYPE html> <html> <head> <title> HTML | DOM clientWidth Property </title> <style> h1 { color: green; font-size: 35px; } #GFG { height: 200px; width: 250px; padding: 40px; margin: 25px; border: 5px solid coral; background-color: green; } </style> </head> <body> <center> <h1>GeeksForGeeks</h1> <h2>DOM clientWidth Property </h2> <div id="GFG"> <h4 style="color:white;font-size:40px;"> GeeksforGeeks </h4> <p id="sudo" style="color:white;"></p> </div> <button onclick="Geeks()">Submit</button> <script> function Geeks() { var w = document.getElementById("GFG"); var x = "viewable Height is: " + w.clientHeight + "px<br>"; x += "viewable width is:: " + w.clientWidth + "px"; document.getElementById("sudo").innerHTML = x; } </script> </center> </body> </html> |
Output:
Before Clicking on the Button:

After clicking on the Button

Supported Browsers: The browser supported by DOM clientWidth property are listed below:
- Google Chrome 1.0
- Internet Explorer 4.0
- Firefox 1.0
- Opera 3.5
- Safari 1.0
Recommended Posts:
- offsetWidth, clientWidth, scrollWidth and Height, respectively in CSS
- HTML | DOM specified Property
- HTML | DOM dir Property
- HTML | DOM URL Property
- HTML | DOM Bdo dir Property
- HTML | DOM id Property
- HTML | DOM name Property
- HTML | DOM li value Property
- HTML | DOM value Property
- HTML | DOM Anchor rel Property
- HTML | DOM KeyboardEvent key Property
- HTML | DOM IFrame name Property
- HTML | DOM Form name Property
- HTML | DOM nodeValue Property
- HTML | DOM Ol reversed 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 contribute@geeksforgeeks.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.



