HTML DOM Object Width Property


The HTML DOM Object Width property is used to set or return the width of an object. This width is set in pixels. Following is the syntax to set the width of an object −

objObject.width

Following is the syntax to return the width of an object −

objObject.width = pixels

Above, pixels is the value set for the width of object.

Let us now see an example to implement the DOM object width property −

Example

 Live Demo

<!DOCTYPE html>
<html>
<body>
   <object id="newObj" width="300" height="200"       data="https://www.tutorialspoint.com/flex/samples/CSSApplication.swf" style="border:2px solid red">      </object>
   <p>Click to update the width.</p>
   <button onclick="display()">Update Width</button>
   <p id="myid"></p>
   <script>
      function display() {
         document.getElementById("newObj").width = "550";
      }
   </script>
</body>
</html>

Output

Now, click the “Update Width” button to update the width −

Updated on: 29-Jun-2020

77 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements