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

Style backgroundOrigin Property

Style Object Reference Style Object

Example

Position the background image relative to the content box:

document.getElementById("myDIV").style.backgroundOrigin="content-box";

Try it yourself »


Definition and Usage

The backgroundOrigin property sets or returns what the background-position property is relative to.

Note: If the background-attachment property for the background image is "fixed", this property has no effect.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The background-origin property is supported in IE9+, Firefox, Opera, Chrome, and Safari.


Syntax

Return the backgroundOrigin property:

object.style.backgroundOrigin

Set the backgroundOrigin property:

object.style.backgroundOrigin="padding-box|border-box|content-box|initial|inherit"

Property Values

Value Description
padding-box Default value. The background image is positioned relative to the padding box
border-box The background image is positioned relative to the border box
content-box The background image is positioned relative to the content box
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: padding-box
Return Value: A String, representing the background-origin property of an element
CSS Version CSS3


Related Pages

CSS reference: background-origin 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 FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook