Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

background-clip — background painting area

The background-clip property sets the boundary for painting an element’s background. It can extend the background underneath the border, stop it at the border’s inner edge, or restrict it to the content area.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

background-clip: border-box | padding-box | content-box;
/* Multiple layers: comma-separated values. */
/* Level 4 draft: <bg-clip>#; <bg-clip> = <visual-box> | [ border-area || text ] */

background-clip sets the background painting area, not the element’s size. Its initial value is border-box; it is not inherited.

border-box includes content, padding, and the area underneath the border. padding-box excludes the border, and content-box also excludes padding. The background is painted behind the border, so an opaque border can hide it.

background-origin sets the background image’s positioning area; background-clip limits its painting. Multiple layers use comma-separated values; the background color uses the bottom layer’s clip. background-clip has no effect on the root element.

The Level 4 draft adds text, clipping to text geometry, and border-area, clipping to the area painted by the border while ignoring border-color transparency. Combining them means the union of both areas. Draft syntax does not establish browser support; these extensions require separate verification.

Examples

<!doctype html>
<meta charset="utf-8">
<title>background-clip</title>
<style>
  body { background: white; }
  .sample {
    width: 120px;
    height: 40px;
    margin: 12px;
    padding: 16px;
    border: 8px dashed black;
    background-color: gold;
  }
  .border { background-clip: border-box; }
  .padding { background-clip: padding-box; }
  .content { background-clip: content-box; }
</style>
<div class="sample border">border-box</div>
<div class="sample padding">padding-box</div>
<div class="sample content">content-box</div>

Result

Three boxes: border-box shows gold through the dashed border gaps; padding-box has white border gaps and gold padding; content-box has white border gaps and white padding, with gold only in the 120 × 40 CSS px content area.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources