Browse documentation

Reference / Backgrounds

Background origin

Choose the box that supplies the origin for background image sizing and positioning.

Working example

Try changing content to padding. The square moves from the inner edge of the padding to the outer edge.

HTML
<div class="h-20 border-4 border-neutral-400 p-3 bg-origin-content bg-no-repeat bg-left-top bg-[size:1.5rem_1.5rem] bg-[linear-gradient(black,black)]"
  role="img" aria-label="An ink square at the content edge"></div>

Class reference

ClassCSS declarations
bg-origin-borderbackground-origin: border-box;
bg-origin-paddingbackground-origin: padding-box;
bg-origin-contentbackground-origin: content-box;
View full generated CSS
Compiled CSS
.bg-origin-border {
  background-origin: border-box;
}
.bg-origin-content {
  background-origin: content-box;
}
.bg-origin-padding {
  background-origin: padding-box;
}