Skip to content
Related Articles

Related Articles

HTML | DOM embed width property
  • Last Updated : 31 Oct, 2019

The DOM embed width property in HTML is used to set or return the value of the width attribute. The width attribute defines the width of the embedded content, in pixels.

Syntax:

  • Return the width property:
    embedObj.width
  • Set the width property:
    embedObj.width = pixels

Property Values:

  • px: Specify the width in pixels of the embedded content.

Return value: It returns a number to show the width of embedded content.

Example:






<!DOCTYPE html> 
<html> 
  
<head> 
    <title>HTML DOM Embed width Property</title> 
</head> 
  
<body> 
    <center> 
        <h1 style="color:green"
            GeeksforGeeks 
        </h1> 
  
        <embed id="embedID" width="400"
            src="https://ide.geeksforgeeks.org"
        <br> 
        <button onclick="GFGfun()"
            Try it 
        </button> 
  
        <p id="pid"></p> 
  
        <script> 
            function GFGfun() { 
                var idwidth = document.getElementById("embedID").width; 
                document.getElementById("pid").innerHTML = idwidth; 
            
        </script> 
    </center> 
</body> 
  
</html> 

Output:
Before clicking the button:

After clicking the button:

Example:




<!DOCTYPE html> 
<html> 
  
<head> 
    <title>HTML DOM Embed width Property</title> 
</head> 
  
<body> 
    <center> 
        <h1 style="color:green"
            GeeksforGeeks 
        </h1> 
  
        <embed id="embedID"
            src="https://ide.geeksforgeeks.org"
        <br> 
        <button onclick="GFGfun()"
            Try it 
        </button> 
  
        <p id="pid"></p> 
  
        <script> 
            function GFGfun() { 
                var idwidth = 
                document.getElementById("embedID").width=400; 
  
                document.getElementById("pid").innerHTML
                     = idwidth; 
            
        </script> 
    </center> 
</body> 
  
</html> 

Output:
Before clicking the button:

After clicking the button:

Supported Browsers: The browsers supported by DOM embed width property are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera
My Personal Notes arrow_drop_up
Recommended Articles
Page :