Open In App

HTML DOM Marquee width Property

Improve
Improve
Like Article
Like
Save
Share
Report

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

Syntax:

  • It returns the marquee width property.

    marqueeObject.width;
  • It sets the marquee width property.

    marqueeObject.width="px/%"

Property values:

  • px: It defines the width value of the marquee.
  • %: It defines the width value of the marquee.

Note: This property is not supported by HTML5.

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

HTML




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

HTML DOM Marquee width Property

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

HTML




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

HTML DOM Marquee width Property

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera


Last Updated : 21 Feb, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads