Background-origin - CSS Property

background-origin

Summary of characteristics of the background-origin property

Quick description
Defines a reference to position the background image.
Status
Standard
Predefined values
padding-box | border-box | content-box
Percentages
Not applicable.
Initial value
padding-box
Inherited by default
No.
Repeatable list.
W3C Module
CSS Backgrounds and Borders Module
 🡇  
 🡅  
Document status: WD (Working Draft)

Document status: CR (Candidate Recommendation)

Syntax diagram of background-origin.

background-origin - Syntax DiagramSyntax diagram of the background-origin CSS property, which set a reference to position the background image. border-box border-box padding-box padding-box content-box content-box , ,background-origin:;background-origin:;
Syntax diagram of the background-origin property.
The links in the diagram provide more details about the values.
Download the diagram in SVG.

In the diagram, the bold terms are the predefined words of CSS, the other terms are described below:

  • In the case of multiple backgrounds, several values are listed separated by a comma.

Description of the background-origin property.

background-origin defines the reference for positioning the background image. The property background-position positions the background image based on this reference.

This does not prevent the background from extending beyond this reference. To limit the background to a certain area of the element, refer to the property background-clip.

background-origin is ineffective if the property background-attachment has the value fixed.

For a general presentation of backgrounds in CSS, refer to the page background.

Values for background-origin.

  • background-origin: padding-box; background-origin: border-box; background-origin: content-box;

    padding-box is the default value. Each of these values corresponds to a point that will serve as a reference for positioning the background with the property background-position.

    background-origin property

  • background-origin: border-box, border-box, ...;

    In the case of multiple backgrounds, several values can be provided for background-origin by separating them with a comma.
    For more information on multiple backgrounds, refer to the page Multiple backgrounds.

  • background-origin: initial; (padding-box) background-origin: inherit; background-origin: revert; background-origin: revert-layer; background-origin: revert-rule; background-origin: unset;

    See the following pages for more details: initial, inherit, revert, revert-layer, revert-rule, unset.

Access the background-origin property via a program

Change the value of background-origin in Javascript.

In JavaScript, depending on the chosen syntax, the property name can be written in kebab-case (a dash between words) or in camel-case (an uppercase letter to separate words). The value, however, must always be written according to the CSS syntax, that is to say in kebab-case.

Javascript
let el = document.getElementById('id'); el.style['background-origin'] = 'border-box'; // or let el = document.getElementById('id'); el.style.backgroundOrigin = 'border-box';

Read in Javascript the value of background-origin.

The code below works when the property has been directly assigned to the element itself, via the style attribute of the HTML, and not by using a CSS selector.

Javascript
let el = document.getElementById('id'); let value = el.style['background-origin']; // or let el = document.getElementById('id'); let value = el.style.backgroundOrigin;

Read the computed value of background-origin in Javascript.

The computed value is the one resulting from the evaluation of the inheritance cascade and the resolution of any conflicts (see the Priorities). The computed value can therefore be the value assigned to the element via the style attribute of the HTML, a value assigned via a CSS selector, an inherited value, or if not, the initial value of the property: padding-box in the case of background-origin.

Javascript
let el = document.getElementById('id'); let value = window.getComputedStyle(el).getPropertyValue('background-origin');

Modify the value of the property background-origin with jQuery.

The name of the property can be written interchangeably in kebab-case notation or in camel-case notation.

JQuery

$('#id').css('background-origin', 'border-box');
// or
$('#id').css('backgroundOrigin', 'border-box');

Read the computed value of the property background-origin with JQuery.

JQuery
let value = $('#id').css('background-origin');

Test it yourself.

The buttons below apply the entered value to the property background-origin and then display either the value as it was applied or the computed value.

Simulator.

The simulator applies the chosen value to the two elements below. For the first, the background image is not repeated; for the second, it is.

background-origin :
Donec dolor mi, iaculis a enim a, pellentesque hendrerit arcu. Nam nec urna eget lacus ornare lacinia a in velit. Suspendisse nec lacus nec elit viverra commodo ut nec sapien. Nunc vitae lorem quam. Ut in dictum sapien, quis maximus urna.
Donec dolor mi, iaculis a enim a, pellentesque hendrerit arcu. Aliquam bibendum eu enim ut tempor. Nam nec urna eget lacus ornare lacinia a in velit. Suspendisse nec lacus nec elit viverra commodo ut nec sapien. Nunc vitae lorem quam. Ut in dictum sapien, quis maximus urna. Aliquam at libero odio. Ut nisl metus, dictum ac varius in, porta at risus. Nam posuere est fringilla pretium rutrum. Aenean in magna ipsum. In nulla enim, pellentesque id tincidunt cursus, ultricies quis ligula.

Browsers compatibility with background-origin.

The property background-origin does not have any compatibility issues with current browsers.

Column 1
Support for the background-origin property that defines the reference for background-position.
1
background-origin
property
Estimated overall support.
96%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

KaiOS Browser

Opéra Mobile

Chrome

Edge

Opéra

Safari

Safari sur IOS

Androïd Brower

Chrome pour Androïd

Firefox pour Androïd

Samsung Internet

Firefox

Baidu Browser

QQ Browser

UC Browser pour Androïd

Opéra mini

Historic of the background-origin property.

  • CSS Backgrounds and Borders Module Level 3

    Level 3 of the specification also explains how to position the background relative to the background area, and how to crop it.
    Regarding borders, the concept of image borders is introduced, as well as the ideas of rounded corners and box shadows.

    Regarding background-origin First definition of the background-origin property.
    WD
    August 02, 2002
    Working Draft.
    CR
    December 17, 2009
    Candidate Recommendation.
    PR
    REC
  • CSS Backgrounds and Borders Module Level 4

    Level 4 of the specification introduces logical values that depend on the writing mode.

    Regarding background-origin No change regarding the background-origin property.
    WD
    November 25, 2025
    Working Draft.
    CR
    PR
    REC

See also, regarding the backgrounds.

Everything concerning backgrounds and borders is described in the specification of W3C CSS Backgrounds and Borders Module. Here is the list of the main properties described in this standard.

Properties:

background
Summary of background properties.
background-attachment
Background image scrolling mode.
background-clip
Defines the extent of the background, especially in relation to the border and padding.
background-color
Sets the background color.
background-image
Defines the background image or gradient (multiple images or gradients can coexist).
Background-origin
Defines a reference to position the background image.
background-position
Defines how the background image is positioned.
background-position-block
Sets the background positioning in the block direction.
background-position-inline
Sets the background positioning along the lines.
background-position-x
Sets how the background image is positioned horizontally.
background-position-y
Defines how the background image is positioned in the vertical direction.
background-repeat
Defines how the background image is repeated.
background-size
Sizing the background image.
border
A shorthand property that defines the set of border parameters: width, style and color.
border-bottom
Sets the parameters of the bottom border of the element (thickness, line style, color).
border-bottom-color
Sets the border line color for the bottom of the element.
border-bottom-left-radius
Sets the radius of the rounded corner at the bottom left.
border-bottom-right-radius
Sets the radius of the rounded corner in the lower right.
border-bottom-style
Sets the line style for the border below the element.
border-bottom-width
Sets the thickness of the border line located below the element.
border-color
Sets the border color for all four sides of the element.
border-end-end-radius
Sets the radius of the corner rounding at the end of line and end of block.
border-end-start-radius
Sets the radius of the corner rounding at the end of line and beginning of the block.
border-image
Langue française
Shorthand of border properties made with images.
border-image-outset
Langue française
Sets the overflow of the border image.
border-image-repeat
Langue française
Defines how the border image is repeated or expanded to cover the desired area.
border-image-slice
Langue française
Defines how the border image is clipped.
border-image-source
Sets the path and file name for the image used to build the border.
border-image-width
Langue française
Sets the thickness of the border when the border is made with an image.
border-left
Sets the three parameters of the left border of the element (thickness, line style, color).
border-left-color
Sets the color of the left border line of the element.
border-left-style
Sets the border style for the left side of the element.
border-left-width
Sets the thickness of the border on the left side of the element.
border-radius
Radius of rounded corners.
border-right
Sets the three parameters of the right border of the element (thickness, line style, color).
border-right-color
Sets the color of the border line on the right side of the element.
border-right-style
Sets the line style for the right border of the element.
border-right-width
Sets the thickness of the border on the right side of the element.
border-start-end-radius
Sets the radius of the corner rounding at the beginning of the line and the end of the block.
border-start-start-radius
Sets the radius of the corner rounding at the beginning of the line and the beginning of the block.
border-style
Sets the line type for some or all four borders around the element (solid, double, dotted...).
border-top
Sets the parameters of the top border of the element (thickness, line style, color).
border-top-color
Sets the color of the border line above the element.
border-top-left-radius
Sets the radius of the rounded corner at the top left.
border-top-right-radius
Sets the radius of the rounded corner in the upper-right.
border-top-style
Sets the line style for the left border of the element.
border-top-width
Sets the thickness of the border line above the element.
border-width
Sets the thickness of the border line around the element.
box-shadow
Applies a shading effect to the frames by indicating all the parameters: color, shadow shift, blur, etc.