Open In App

HTML | DOM Style backgroundRepeat Property

The backgroundRepeat property in HTML DOM is used to set or return the CSS backgroundRepeat property. It also checks whether the background-image is repeated or not. 

Syntax:



object.style.backgroundRepeat 
object.style.backgroundRepeat = "repeat|repeat-x|repeat-y|
no-repeat|initial|inherit" 

Property Values:

Return Value: It returns a string value which represent how to background image repeated. 



Example 1: 




<!DOCTYPE html>
<html>
    <head>
        <title>
            DOM Style background-repeat property
        </title>
         
        <style>
            body {
                background-image: url(
                background-size: 200px 150px;
                text-align:center;
            }
        </style>
    </head>
     
    <body>
        <h1>GeeksforGeeks</h1>
         
        <h2>
            DOM Style backgroundRepeat Property
        </h2>
         
        <button onclick = "myGeeks()">
            Submit
        </button>
         
        <script>
            function myGeeks() {
                document.body.style.backgroundRepeat = "no-repeat";
            }
        </script>
    </body>
</html>                                    

Output: 

Before Click on the button:

  

After Click on the button: 

 

Example 2: 




<!DOCTYPE html>
<html>
    <head>
        <title>
            DOM Style background-repeat property
        </title>
         
        <style>
            body {
                background-image: url(
                background-repeat: repeat-y;
                background-size: 200px 150px;
                text-align:center;
            }
        </style>
    </head>
     
    <body>
        <h1>GeeksforGeeks</h1>
         
        <h2>
            DOM Style backgroundRepeat Property
        </h2>
         
        <button onclick = "myGeeks()">
            Submit
        </button>
         
        <script>
            function myGeeks() {
                document.body.style.backgroundRepeat = "repeat-x";
            }
        </script>
    </body>
</html>                   

Output: 

Before Click on the button:

  

After Click on the button: 

 

Supported Browsers: The browser supported by DOM Style backgroundRepeat property are listed below:


Article Tags :