background-origin property

Image Tutorials

Definition and Usage

The background-origin CSS property determines the background positioning area, that is the position of the origin of an image specified using the background-image CSS property.

Note that background-origin is ignored when background-attachment is fixed.

If the value of this property is not set in a background shorthand property that is applied to the element after the background-origin CSS property, the value of this property is then reset to its initial value by the shorthand property.

  • Initialpadding-box
  • Applies toall elements
  • Inheritedno
  • Mediavisual
  • Computed Valueas specified
  • Animatableno
  • Canonical orderthe unique non-ambiguous order defined by the formal grammar

Syntax

Formal syntax: <box>#
background-origin: border-box
background-origin: padding-box
background-origin: content-box
background-origin: inherit

Values

border-box
The background extends to the outside edge of the border (but underneath the border in z-ordering).
padding-box
No background is drawn below the border (background extends to the outside edge of the padding).
content-box
The background is painted within (clipped to) the content box.

Examples

1 .example {
2    border10px double;
3    padding10px;
4    backgroundurl('image.jpg');
5    background-positioncenter left;
6    /* The background will be inside the padding */
7    background-origin: content-box;
8 }
1 div {
2   background-imageurl('logo.jpg'), url('mainback.png');
3   background-positiontop right0px 0px;
4   background-origin: content-box, padding-box;
5 }

Compatibility

Desktop browsers

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 [3] 4.0 (2.0) 9.0 [2] 10.5 3.0 (522) [3]
content-box 1.0 [3] 4.0 (2.0) 9.0 [2] Not supported 3.0 (522) [3]

Mobile browsers

Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support NA NA NA NA NA
content-box NA NA NA NA NA

Rate article