CSS background-origin Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The background-origin property sets the background positioning area. That is the box used when background-position and background-size place a background-image. Choose the border edge, the padding edge, or the content edge.

The initial value is padding-box. The property is not inherited. It applies to every element, including ::first-letter and ::first-line. With several images, list one keyword per layer. Origin is ignored when background-attachment is fixed.

Standard-track.

Not deprecated and not experimental. Baseline widely available. Do not confuse it with background-clip, which only limits how far the paint shows.

CSS Syntax

syntax.css
background-origin: border-box | padding-box | content-box | initial | inherit;

For multiple images, write a comma list such as content-box, padding-box. Each keyword matches one image in the same order.

Property Values

ValueDescriptionTry it
padding-boxDefault. Position from the padding edge, just inside the borderTry it
border-boxPosition from the outer border edgeTry it
content-boxPosition from the content edge, inside the paddingTry it
content-box, padding-boxOne keyword per background layer, in image orderTry it
initialResets this property to padding-boxTry it
inheritCopies this property from the parent elementTry it

How to Use background-origin

Give the box a border or padding, place a smaller image, then choose which edge that image is measured from.

  1. Set a background-image. Origin only changes where that image is positioned from.
  2. Add a thick border and/or clear padding so the three boxes are easy to tell apart.
  3. Use background-repeat: no-repeat, a modest background-size, and background-position: left top so the shift is visible.
  4. Set background-origin on that element. It is not inherited.
PieceRequired?Role
background-imageYesThe paint whose position area you are choosing
Border and/or paddingYes, to see a changeCreates different edges for border, padding, and content
no-repeat + size + positionRecommendedA small corner image makes origin shifts obvious
KeywordYesborder-box, padding-box, or content-box

Live Preview

A dashed border, padding, and a blue circle at the top left. Change background-origin and watch where the circle starts.

Dashed line = border. Space inside it = padding. The label sits in the content box.

Origin
Content area

background-origin: padding-box

CSS Examples

Each snippet adds only what background-origin needs: a border, padding, a small image, and the keyword. Use Try It Yourself for a live editor.

Example 1 — padding-box (Default)

Start the blue circle just inside the dashed border.

CSS
<style>
  div {
    padding: 24px;
    border: 12px dashed #64748b;
    background-color: #f1f5f9;
    background-image: radial-gradient(circle, #2563eb 0 28px, transparent 29px);
    background-repeat: no-repeat;
    background-size: 64px 64px;
    background-position: left top;
    background-origin: padding-box;
  }
</style>

<div>Content area</div>
Try It Yourself

How It Works

  1. Draw the three boxes. The dashed line is the border. The space inside it is padding. The words sit in the content box.
  2. Place a small image. A 64px circle with no-repeat and left top makes the origin easy to see.
  3. Measure from the padding edge. padding-box puts the circle's top-left at the inner edge of the border.
  4. This is the default. Omitting the property gives the same result as background-origin: padding-box.

Example 2 — border-box

Start the circle from the outer border edge so it can sit under the dashes.

CSS
<style>
  div {
    padding: 24px;
    border: 12px dashed #64748b;
    background-color: #f1f5f9;
    background-image: radial-gradient(circle, #2563eb 0 28px, transparent 29px);
    background-repeat: no-repeat;
    background-size: 64px 64px;
    background-position: left top;
    background-origin: border-box;
  }
</style>

<div>Content area</div>
Try It Yourself

How It Works

  1. Same image and box. Only the origin keyword changes from Example 1.
  2. Measure from the border edge. border-box places left top at the outer corner of the border.
  3. The circle can sit under the border. Dashes may cut across the blue because the positioning area includes the border width.
  4. Clip is separate. Whether you still see paint under the border also depends on background-clip, which defaults to border-box.

Example 3 — content-box

Start the circle at the content edge, after the padding.

CSS
<style>
  div {
    padding: 24px;
    border: 12px dashed #64748b;
    background-color: #f1f5f9;
    background-image: radial-gradient(circle, #2563eb 0 28px, transparent 29px);
    background-repeat: no-repeat;
    background-size: 64px 64px;
    background-position: left top;
    background-origin: content-box;
  }
</style>

<div>Content area</div>
Try It Yourself

How It Works

  1. Skip the padding in the measure. content-box starts left top at the content edge.
  2. The circle moves inward. The 24px padding pushes the image away from the dashed border.
  3. Useful for tight alignment. Pair this with content-sized art when the image should line up with the text, not the padding.
  4. Compare the three. Border → padding → content is the order from outside in. That is the same order the keywords name.

Edge Cases & Pitfalls

If every keyword looks the same, one of these is usually why.

fixed

Ignored when attachment is fixed

With background-attachment: fixed, the image is pinned to the viewport. Origin no longer chooses a box on the element.

clip

Origin is not clip

background-clip limits painting. Origin only changes the positioning area. You can set them to different boxes on purpose.

cover

A full-bleed image hides the change

With background-size: cover and repeat, every origin can look identical. Use a smaller, non-repeating image at a known corner to study the property.

shorthand

One box in the shorthand sets both

In the background shorthand, a single border-box / padding-box / content-box value sets both origin and clip. Two values mean origin first, then clip.

box

No border and no padding, no visible shift

If padding and border are zero, the three boxes share the same edges. Add padding or a thick border before comparing keywords.

Browser Support

background-origin is a browser painting property. Node.js, Deno, and Bun do not apply it. All three keywords are Baseline and widely available.

✓ Baseline · Widely available since 2015

background-origin

Chrome 4+, Firefox 4+, Safari 3.1+, Edge 12+, Opera 15+, Samsung Internet 4+, Internet Explorer 9+. Older Internet Explorer 8 and below lack the property.

97% Global support
Google Chrome 4+
Full support
Mozilla Firefox 4+
Full support
Apple Safari 3.1+
Full support
Microsoft Edge 12+
Full support
Opera 15+
Full support
Samsung Internet 4+
Full support
Internet Explorer 9+
Full support
background-origin Widely supported

Bottom line: Safe to use in current browsers. Internet Explorer 8 and older do not support it. Remember that fixed attachment still disables origin on every engine.

Key Takeaways

  • Role: choose the box used for background-position and background-size.
  • Keywords: border-box, padding-box (default), content-box.
  • Not clip: origin positions; background-clip paints or hides.
  • Fixed: with background-attachment: fixed, origin is ignored.

One line: background-origin answers “which edge is left top measured from?”

Frequently Asked Questions

It sets the background positioning area. background-position and background-size are measured from that box: the border box, the padding box, or the content box.
padding-box. The positioning area starts just inside the border, at the outer edge of the padding.
background-origin decides where position and size are calculated from. background-clip decides how far the background paint is allowed to show. They often use the same keywords, but they do different jobs.
You need a visible border or padding, a non-repeating image that is smaller than the box, and a clear background-position such as left top. With a full-bleed cover image, every origin can look the same. Origin is also ignored when background-attachment is fixed.
Yes. Gradients are background images. Origin changes the box used for their position and size when those properties depend on the element's edges.
It is Baseline and widely available. Unprefixed support is solid in Chrome 4+, Firefox 4+, Safari 3.1+, Edge 12+, and Internet Explorer 9+. It is a browser painting property. Node.js, Deno, and Bun do not apply it.

Next: background-position

Learn how to place the image inside the positioning area you just chose.

background-position tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful