Computer >> Computer tutorials >  >> Programming >> HTML

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

<!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

HTML DOM Object Width Property

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

HTML DOM Object Width Property