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:
- It is used to returns the backgroundRepeat property.
object.style.backgroundRepeat
- It is used to set the backgroundRepeat property.
object.style.backgroundRepeat = "repeat|repeat-x|repeat-y| no-repeat|initial|inherit"
Property Values:
- repeat: It is used to repeat the background image both horizontally and vertically. It is the default value.
- repeat-x: It is used to repeat the background image horizontally.
- repeat-y: It is used to set the background image repeated only vertically.
- no-repeat: It does not repeat the background image. It displays the background image only once.
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:
- Google Chrome 1.0
- Internet Explorer 4.0
- Firefox 1.0
- Opera 1.0
- Safari 3.5
Recommended Posts:
- HTML | DOM Style right Property
- HTML | DOM Style top Property
- HTML | DOM Style animationName Property
- HTML | DOM Style order Property
- HTML | DOM Style animationDelay Property
- HTML | DOM Style borderBottomColor Property
- HTML | DOM Style minWidth Property
- HTML | DOM Style transform Property
- HTML | DOM Style flexDirection Property
- HTML | DOM Style borderBottom Property
- HTML | DOM Style borderCollapse Property
- HTML | DOM Style color Property
- HTML | DOM Style backfaceVisibility Property
- HTML | DOM Style animationTimingFunction Property
- HTML | DOM Style borderRightStyle Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


