Style backgroundRepeat Property
Example
Set a background-image to no-repeat:
document.body.style.backgroundRepeat = "repeat-y";
Try it Yourself »
More "Try it Yourself" examples below.
Description
The backgroundRepeat property sets or returns how to repeat (tile) a background-image.
See Also:
HTML Styles: The background Property
CSS Tutorial: CSS Backgrounds
CSS3 Tutorial: CSS3 Backgrounds
CSS Reference: The background-repeat property
Syntax
Return the backgroundRepeat property:
object.style.backgroundRepeat
Set the backgroundRepeat property:
object.style.backgroundRepeat = "repeat|repeat-x|repeat-y|no-repeat|initial|inherit"
Property Values
Value | Description |
---|---|
repeat | The background image is repeated both vertically and horizontally. This is default |
repeat-x | The background image is only repeated horizontally |
repeat-y | The background image is only repeated vertically |
no-repeat | The background-image is not repeated |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technical Details
Default Value: | repeat |
---|---|
Return Value: | A String, representing how a background-image is repeated |
CSS Version | CSS1 |
Browser Support
backgroundRepeat
is a CSS1 (1996) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
More Examples
Example
Change the backgroundRepeat property of a specified DIV element:
document.getElementById("myDIV").style.backgroundRepeat = "repeat-x";
Try it Yourself »
Example
Set a background-image to repeat horizontally or vertically:
function repeatVer()
{
document.body.style.backgroundRepeat = "repeat-y";
}
function repeatHor() {
document.body.style.backgroundRepeat = "repeat-x";
}
Try it Yourself »
Example
Return the background-repeat value of a document:
alert(document.body.style.backgroundRepeat);
Try it Yourself »
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.