CSS background-origin Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Backgrounds & Layout

What You’ll Learn

The background-origin property defines the background positioning area. It controls whether a background image is positioned relative to the border, padding, or content box of an element.

01

Positioning Area

Where placement starts.

02

Syntax

Three box keywords.

03

padding-box

Default origin value.

04

content-box

Tightest origin box.

05

background-clip

Related clipping property.

06

With position

Works with background-position.

Definition and Usage

The background-origin CSS property sets the background positioning area of a background image. In other words, it decides which box is used as the reference frame for properties like background-position and background-size.

This is especially useful when an element has visible padding or borders and you want a small icon, badge, or decorative background placed relative to a specific part of the box.

💡
Beginner Tip

To see background-origin clearly, use a small non-repeating background image or gradient together with thick padding and a visible border.

📝 Syntax

Apply background-origin to an element that already has a background-image:

syntax.css
selector {

  background-origin: <box>;

}

Basic Example

background-origin.css
.box {

  padding: 20px;

  border: 20px solid #333;

  background-image: url("pattern.svg");

  background-repeat: no-repeat;

  background-origin: content-box;

}

Syntax Rules

  • The initial value is padding-box.
  • Accepted values are border-box, padding-box, and content-box.
  • It affects the positioning area, not necessarily the painted clipping area.
  • Use it together with background-position and background-size for precise placement.
  • Compare it with background-clip, which controls where the background is painted.

⚡ Quick Reference

QuestionAnswer
Initial valuepadding-box
Applies toBackground positioning area of an element
InheritedNo
AnimatableNo
Common useIcon placement, inset backgrounds, bordered cards

Default Value

The initial value of background-origin is padding-box. That means the background positioning area starts at the outer edge of the padding, just inside the border.

💎 Property Values

These are the three background-origin keywords beginners use most often.

ValueExampleMeaning
border-boxbackground-origin: border-box;Positioning starts from the outer edge of the border box
padding-boxbackground-origin: padding-box;Positioning starts from the outer edge of the padding box
content-boxbackground-origin: content-box;Positioning starts from the top-left of the content box
border-box

The positioning area includes the border. Useful when the border edge should act as the reference point.

The marker starts farthest out.

padding-box

The default value. Positioning starts just inside the border at the padding edge.

Most common default behavior.

content-box

Positioning starts inside the padding, aligned with the content area only.

Creates the most inset placement.

background-origin vs background-clip

PropertyControlsBest for
background-originWhere the background positioning area startsAligning backgrounds with border, padding, or content edges
background-clipWhere the background is painted and clippedInset backgrounds, gradient text, framed panels

👀 Live Preview

These panels use the same small background marker, border, and padding. Only the origin value changes:

border-box
padding-box
content-box

Watch how the blue marker shifts inward as the origin box gets tighter.

Examples Gallery

Try background-origin with content-box, padding-box vs border-box, background-position, and a three-value comparison.

📚 Origin Boxes

Choose which box the browser should use as the reference for background placement.

Example 1 — content-box Origin

Start the background positioning area from the content box so padding pushes the image inward.

content-origin.css
.box {

  padding: 20px;

  border: 12px solid #334155;

  background-image: radial-gradient(circle, #f97316 0 36px, transparent 37px);

  background-repeat: no-repeat;

  background-size: 80px 80px;

  background-origin: content-box;

}
Try It Yourself

How It Works

The orange marker is positioned relative to the content box, so it appears inset from both the border and the padding.

Example 2 — padding-box vs border-box

Compare the default padding-box origin with border-box on the same bordered panel.

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

.border-box { background-origin: border-box; }
Try It Yourself

How It Works

With border-box, the marker starts farther out because the positioning area includes the border edge.

🎨 Placement Control

Combine background-origin with background-position for precise decorative placement.

Example 3 — Origin with background-position

Change the origin box to control what background-position: bottom right; means.

origin-position.css
.panel {

  padding: 24px;

  border: 10px dashed #64748b;

  background-image: linear-gradient(135deg, #a855f7, #ec4899);

  background-repeat: no-repeat;

  background-size: 64px 64px;

  background-position: bottom right;

  background-origin: content-box;

}
Try It Yourself

How It Works

The small gradient square is anchored to the bottom-right corner of the content box, not the outer border edge.

Example 4 — Compare All Origin Values

Use the same background settings with each origin keyword to compare the placement quickly.

origin-compare.css
.border-box { background-origin: border-box; }

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

.content-box { background-origin: content-box; }
Try It Yourself

How It Works

Each origin value shifts the reference box inward, which moves the same background marker to a different starting point.

🧠 How background-origin Works

1

You add a background image

Set a gradient, icon, or image using background-image.

Background
2

You choose an origin box

Pick border-box, padding-box, or content-box.

Origin rule
3

Position and size use that box

Properties like background-position and background-size are calculated from the chosen origin area.

Placement
=

Precise background placement

You can align decorative backgrounds with borders, padding, or content edges.

Universal Browser Support

background-origin is supported in all modern browsers and is reliable for background placement in real projects.

Baseline · Modern browsers

Control background placement in today’s browsers

Chrome, Firefox, Safari, Edge, and Opera support all three origin keywords.

97% Modern browser support
Google Chrome1+ · Desktop & Mobile
Full support
Mozilla Firefox4+ · Desktop & Mobile
Full support
Apple Safari3+ · macOS & iOS
Full support
Microsoft Edge12+ · Modern versions
Full support
Opera10.5+ · Modern versions
Full support

Fallback behavior

In unsupported browsers, backgrounds still render using the default padding-box origin behavior.

💻
Internet Explorer 8 and earlier Limited support · Default placement still works
Partial
background-origin property 97% supported

Bottom line: Use background-origin confidently in modern projects when you need precise background placement.

Conclusion

The background-origin property gives you control over the background positioning area. Whether you want a decorative image aligned with the border, padding, or content edge, this property helps you place backgrounds exactly where you need them.

Start with the default padding-box, then compare content-box and border-box when working with bordered or padded elements.

💡 Best Practices

✅ Do

  • Use thick borders and padding when teaching or testing origin values
  • Pair origin with background-position and background-size
  • Use small non-repeating backgrounds to make differences obvious
  • Compare origin with background-clip when learning both properties
  • Stick with padding-box unless you need tighter placement

❌ Don’t

  • Confuse background-origin with background-clip
  • Expect visible differences with full-cover backgrounds only
  • Forget that padding-box is the default
  • Assume origin changes clipping behavior by itself
  • Use origin alone without a background image or gradient

Key Takeaways

Knowledge Unlocked

Five things to remember about background-origin

Use these points when placing backgrounds inside bordered elements.

5
Core concepts
📝02

Three Boxes

border, padding, content.

Values
👁03

padding-box Default

Common starting point.

Default
🛠04

Not clip

Origin vs painted area.

Compare
📍05

With Position

Works with background-position.

Layout

❓ Frequently Asked Questions

The background-origin property defines the background positioning area. It controls whether background-position and background-size are calculated from the border box, padding box, or content box.
The initial value is padding-box, which means the background positioning area starts at the outer edge of the padding, just inside the border.
background-origin decides where the background positioning area begins. background-clip decides where the background is actually painted and clipped.
padding-box is the default and works well for most layouts. Use content-box when you want backgrounds aligned tightly to content, or border-box when the border area should be included in positioning.
Yes. It affects any background image layer, including gradients, when background-size or background-position makes the effect depend on the element's box edges.

Practice in the Live Editor

Open the HTML editor, add borders and small background markers, and experiment with background-origin instantly.

HTML Editor →

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.

5 people found this page helpful