CSS background-origin Property

CSS background-origin property specifies the origin position of the background image for an element.

CSS background-origin property does not effect if background-attachment is fixed value.

Usages

The following table outline the usages and version history of this property.

Default value: padding-box
Applies to: All elements
Inherited: No
Version: CSS3
JavaScript Syntax: object.style.backgroundOrigin = "border-box"

Syntax

Here is a syntax for the CSS background-origin property

background-position: padding-box | border-box | content-box | initial | inherit;

Property Values

The following table describes the values of this property.

Value Description
padding-box Default. Specifies that background image positioned top left corner of the padding edge
border-box Specifies that background image positioned top left corner of the border edge
content-box Specifies that background image positioned top left corner of the content edge
initial Sets default value of this property
inherit Inherits this property from its parent element.

Examples

The example below shows to sets background origin padding-box, border-box, content-box values.

.padding {
  background-origin: padding-box;
}
.border {
  background-origin: border-box;
}
.content {
  background-origin: content-box;
}

Run it...   »

Browser Compatibility

  • Google Chrome 4+
  • Mozilla Firefox 4+
  • Internet Explorer 9+
  • Opera 10.5+
  • Safari 3.1+

Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.