Open In App

HTML DOM Marquee width Property

The HTML DOM Marquee width property is used to set or return the value of the width attribute of the <marquee> element.

Syntax:



Property values:

Note: This property is not supported by HTML5.

Example 1: Below HTML code returns the marquee width property.




<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML DOM Marquee width property
        </title>
    </head>
      
    <body style="text-align:center;">
      
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
          
        <h2>DOM Marquee width Property</h2>
          
        <marquee id="marqueeID" direction="right" loop="3" 
                 bgcolor="green" width="250px" height="40px">
            GeeksforGeeks:A computer Science Portal for Geeks
        </marquee>        
        <br><br>
          
        <button onclick="btnClick()">
          Return width of marquee tag 
        </button>
        <p id ="paraID"></p>
  
        <script>
            function btnClick() {
                var txt = document.getElementById("marqueeID").width;
               document.getElementById("paraID").innerHTML = txt;
            }
        </script>    
    </body>
</html>

Output:

HTML DOM Marquee width Property

Example 2: Below HTML code sets the Marquee width property. 




<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML DOM Marquee width property
        </title>
    </head>
      
    <body style="text-align:center;">
      
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
          
        <h2>DOM Marquee width Property</h2>
          
        <marquee id="marqueeID" direction="right" loop="3" 
                 bgcolor="green" width="250px" height="40px">
            GeeksforGeeks:A computer Science Portal for Geeks
        </marquee>        
        <br><br>
          
        <button onclick="btnClick()">
           Change width of marquee tag 
        </button>
         <p id ="paraID"></p>
  
        <script>
            function btnClick() {
                var txt = document.getElementById("marqueeID").width = "100px";
                document.getElementById("paraID").innerHTML = txt;
            }
        </script>    
    </body>
</html>

Output:

HTML DOM Marquee width Property

Supported Browsers:


Article Tags :