Open In App

HTML DOM Marquee Object

The HTML DOM Marquee Object is used to represent the HTML <marquee> tag. We know that the <marquee> tag is used to move the content from horizontal to vertical or left to right or right to left. 

Syntax



It is used to access the marquee tag.

document.getElementById("id");  

It is used to create a marquee tag.



document.createElement("MARQUEE");

Note: This object is depreciated from HTML 5.

Property values:

Methods 

Example 1: Below HTML code illustrates how to create a marquee object. 




<!DOCTYPE html>
<html>
 
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
     
    <h2>DOM Marquee Object</h2>
     
    <b>
        Click on the below button to
        create a marquee object
    </b>
     
     
 
<p></p>
 
 
     
    <button onclick="createMarqueObject()">
        Create Marquee Object
    </button>
 
    <script>
        function createMarqueObject() {
            var elementVar = document.createElement("MARQUEE");
            var txt = document.createTextNode(
                "GeeksforGeeks:A computer Science Portal for Geek");
            elementVar.appendChild(txt);
            document.body.appendChild(elementVar);
        }
    </script>
</body>
 
</html>

Output:

Example 2: Below HTML code illustrates how to change the background color and font size of the marquee element.




<!DOCTYPE html>
<html>
 
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
 
    <h2>DOM Marquee Object</h2>
 
    <marquee id="marqueeID">
        GeeksforGeeks:A computer Science
        Portal for Geeks
    </marquee>
    <br><br>
 
    <button onclick="btnClick()">
        Change BackGround Color
    </button>
 
    <script>
        function btnClick() {
            var txt = document.getElementById("marqueeID");
            txt.style.backgroundColor = "green";
            txt.style.fontSize = "25px";
        }
    </script>
</body>
 
</html>

Output:

Supported browsers:


Article Tags :