X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Style backgroundRepeat Property

Style Object Reference Style Object

Example

Set a background-image to no-repeat:

document.body.style.backgroundRepeat="repeat-y";

Try it yourself »


Definition and Usage

The backgroundRepeat property sets or returns how to repeat (tile) a background-image.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The backgroundRepeat property is supported in all major browsers.


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


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 »


Related Pages

CSS tutorial: CSS Background

CSS reference: background-position property

CSS reference: background-repeat property

HTML DOM reference: background property


Style Object Reference Style Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook