1. Introduction
This subsection is not normative.
When elements are rendered according to the CSS box model [CSS-BOX-3], each element is either not displayed at all, or formatted as one or more rectangular boxes. Each box has a rectangular content area, a band of padding around the content, a border around the padding, and a margin outside the border. (The margin may actually be negative, but margins have no influence on the background and border.)
The properties of this module deal with the decoration of the border area and with the background of the content, padding, and border areas. Additionally the box may be given a “drop-shadow” effect with the box-shadow property.
If an element is broken into multiple box fragments, box-decoration-break [CSS-BREAK-3] defines how the borders and background are divided over the various fragments. (An element can result in more than one fragment if it is broken at the end of a line, at the end of a column or at the end of a page; and continued in the next line, column or page.)
The relative stacking order of backgrounds, borders, and shadows is given in this module. For how these layers interact with other rendered content, see Appendix E “Elaborate description of Stacking Contexts” in [CSS2].
1.1. Module Interactions
This module replaces and extends the background and border features defined in [CSS2] sections 8.5 and 14.2.
All properties in this module apply to the ::first-letter pseudo-element. The background properties and border-radius properties also apply to the ::first-line pseudo-element. The UA may (but is not required to) apply the border-image or box-shadow properties to ::first-line. The UA must not apply the border-color/style/width properties to ::first-line. [CSS2]
1.2. Value Definitions
This specification follows the CSS property definition conventions from [CSS2] using the value definition syntax from [CSS-VALUES-3]. Value types not defined in this specification are defined in CSS Values & Units [CSS-VALUES-3]. Combination with other CSS modules may expand the definitions of these value types. For example, combining with CSS Images allows for using CSS gradients as background-image or border-image values. [CSS-IMAGES-3]
In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the CSS-wide keywords as their property value. For readability they have not been repeated explicitly.
2. Backgrounds
Each box has a background layer that may be fully transparent (the default), or filled with a color and/or one or more images. The background properties specify what color (background-color) and images (background-image) to use, and how they are sized, positioned, tiled, etc.
The background properties are not inherited, but the parent box’s background will shine through by default because of the initial transparent value on background-color.
2.1. Layering Multiple Background Images
The background of a box can have multiple background image layers. The number of layers is determined by the number of comma-separated values in the background-image property. Note that a value of none still creates a layer.
Tests
Each of the background images is sized, positioned, and tiled according to the corresponding value in the other background properties. The lists are matched up from the first value: excess values at the end are not used. If a property doesn’t have enough comma-separated values to match the number of layers, the UA must calculate its used value by repeating the list of values until there are enough.
background-image: url(flower.png), url(ball.png), url(grass.png); background-position: center center, 20% 80%, top left, bottom right; background-origin: border-box, content-box; background-repeat: no-repeat;
has exactly the same effect as this set, with the extra position dropped and the missing values for background-origin and background-repeat filled in (emphasized for clarity):
background-image: url(flower.png), url(ball.png), url(grass.png); background-position: center center, 20% 80%, top left; background-origin: border-box, content-box, border-box; background-repeat: no-repeat, no-repeat, no-repeat;
The first image in the list is the layer closest to the user, the next one is painted behind the first, and so on. The background color, if present, is painted below all of the other layers.
Note: The border-image properties can also define a background image, which, if present, is painted on top of the background layers created by the background properties.
2.2. Base Color: the background-color property
Name: | background-color |
---|---|
Value: | <color> |
Initial: | transparent |
Applies to: | all elements |
Inherited: | no |
Percentages: | N/A |
Computed value: | computed color |
Canonical order: | per grammar |
Animation type: | by computed value |
Tests
- background-color-animation-backdrop-infinite-duration-crash.html (live test) (source)
- background-color-animation-element-not-visible-at-current-viewport.html (live test) (source)
- background-color-animation-fallback-additive-keyframe.html (live test) (source)
- background-color-animation-fallback-missing-0-percent.html (live test) (source)
- background-color-animation-fallback-missing-100-percent.html (live test) (source)
- background-color-animation-fallback-replace.html (live test) (source)
- background-color-animation-field-crash.html (live test) (source)
- background-color-animation-fragmented.html (live test) (source)
- background-color-animation-half-opaque.html (live test) (source)
- background-color-animation-in-body.html (live test) (source)
- background-color-animation-non-empty-no-draw-crash.html (live test) (source)
- background-color-animation-non-zero-size-element-change-to-zero.html (live test) (source)
- background-color-animation-pseudo-element.html (live test) (source)
- background-color-animation-removed-element-crash.html (live test) (source)
- background-color-animation-single-keyframe.html (live test) (source)
- background-color-animation-three-keyframes1.html (live test) (source)
- background-color-animation-three-keyframes2.html (live test) (source)
- background-color-animation-three-keyframes3.html (live test) (source)
- background-color-animation-will-change-contents.html (live test) (source)
- background-color-animation-with-blur.html (live test) (source)
- background-color-animation-with-images.html (live test) (source)
- background-color-animation-with-mask.html (live test) (source)
- background-color-animation-with-table1.html (live test) (source)
- background-color-animation-with-table2.html (live test) (source)
- background-color-animation-with-table3.html (live test) (source)
- background-color-animation-with-table4.html (live test) (source)
- background-color-animation-with-zero-playbackRate.html (live test) (source)
- background-color-animation-zero-size-element-change-to-non-zero.html (live test) (source)
- background-color-animation-zero-size-element.html (live test) (source)
- background-color-animation.html (live test) (source)
- background-color-interpolation.html (live test) (source)
- background-color-scroll-into-viewport.html (live test) (source)
- background-color-transition-colormix.html (live test) (source)
- background-color-transition-currentcolor.html (live test) (source)
- background-color-transition.html (live test) (source)
- background-color-transparent-animation-in-body.html (live test) (source)
- background-color-animation-with-zero-alpha.html (live test) (source)
- background-color-transition-obscured.html (live test) (source)
- background-color-transition-with-delay.html (live test) (source)
- background-color-transition-with-initially-transparent.html (live test) (source)
- two-background-color-animation-diff-length1.html (live test) (source)
- two-background-color-animation-diff-length2.html (live test) (source)
- two-background-color-animation-diff-length3.html (live test) (source)
- background-none-none-and-color.html (live test) (source)
- background-color-body-propagation-001.html (live test) (source)
- background-color-body-propagation-002.html (live test) (source)
- background-color-body-propagation-003.html (live test) (source)
- background-color-body-propagation-004.html (live test) (source)
- background-color-body-propagation-005.html (live test) (source)
- background-color-body-propagation-006.html (live test) (source)
- background-color-body-propagation-007.html (live test) (source)
- background-color-body-propagation-008.html (live test) (source)
- background-color-body-propagation-009.html (live test) (source)
- background-color-clip.html (live test) (source)
- background-color-root-propagation-001.html (live test) (source)
- background-color-root-propagation-002.html (live test) (source)
- bg-color-with-gradient.html (live test) (source)
- child-move-reveals-parent-background.html (live test) (source)
- color-mix-currentcolor-background-repaint-parent.html (live test) (source)
- color-mix-currentcolor-background-repaint.html (live test) (source)
- simple-bg-color.html (live test) (source)
- inheritance.sub.html (live test) (source)
- inline-background-rtl-001.html (live test) (source)
- background-color-computed.html (live test) (source)
- background-color-invalid.html (live test) (source)
- background-color-valid.html (live test) (source)
- color-behind-images.htm (visual test) (source)
This property sets the background color of a box. This color is drawn behind any background images.
The background color is clipped according to the background-clip value associated with the bottom-most background image layer.
2.3. Image Sources: the background-image property
Name: | background-image |
---|---|
Value: | <bg-image># |
Initial: | none |
Applies to: | all elements |
Inherited: | no |
Percentages: | N/A |
Computed value: | list, each item either an <image> or the keyword none |
Canonical order: | per grammar |
Animation type: | discrete |
Tests
- background-image-001.html (live test) (source)
- background-image-002.html (live test) (source)
- background-image-003.html (live test) (source)
- background-image-004.html (live test) (source)
- background-image-005.html (live test) (source)
- background-image-006.html (live test) (source)
- background-image-007.html (live test) (source)
- background-image-centered-with-border-radius.html (live test) (source)
- background-image-centered.html (live test) (source)
- background-image-cors-no-reload.html (live test) (source)
- background-image-cover-zoomed-1.html (live test) (source)
- background-image-first-letter.html (live test) (source)
- background-image-first-line.html (live test) (source)
- background-image-gradient-currentcolor-conic-repaint.html (live test) (source)
- background-image-gradient-currentcolor-linear-repaint.html (live test) (source)
- background-image-gradient-currentcolor-radial-repaint.html (live test) (source)
- background-image-gradient-currentcolor-visited.html (live test) (source)
- background-image-gradient-interpolation-repaint.html (live test) (source)
- background-image-large-with-auto.html (live test) (source)
- background-image-none-gradient-repaint.html (live test) (source)
- background-image-shared-stylesheet.html (live test) (source)
- background-image-table-cells-straddling-no-repeat.html (live test) (source)
- background-image-table-cells-zoomed.html (live test) (source)
- background-image-with-border-radius-fidelity.html (live test) (source)
- background-image-interpolation.html (live test) (source)
- inheritance.sub.html (live test) (source)
- background-image-computed.sub.html (live test) (source)
- background-image-invalid.html (live test) (source)
- background-image-valid.html (live test) (source)
This property specifies the background image(s) of an element. Images are drawn with the first specified one on top (closest to the user) and each subsequent image behind the previous one. The property’s value is given as a comma-separated list of <bg-image> values where
<bg-image> = <image> | none
A value of none counts as a background image layer but draws nothing. An image that is empty (zero width or zero height), that fails to download, or that cannot be displayed (e.g., because it is not in a supported image format) likewise counts as a layer but draws nothing.
See § 2.1 Layering Multiple Background Images for how background-image interacts with other comma-separated background properties to form each background image layer.
When setting a background image, authors should also specify a background-color that will preserve contrast with the text for when the image is unavailable.
For accessibility reasons, authors should not use background images as the sole method of conveying important information. See Web Content Accessibility Guideline F3 [WCAG20]. Images are not accessible in non-graphical presentations, and background images specifically might be turned off in high-contrast display modes.
Note: Stylistic foreground images can be provided in CSS with the content property. Semantically-important foreground images should be provided in the document markup, e.g. with the <img> tag in HTML.
Note: Media fragments can be used to display a portion of an image. The CSS Images module will provide fallback syntax for image formats and include additional controls for image display.
html { background-image: url("marble.svg") } p { background-image: none } div { background-image: url(tl.png), url(tr.png) } main { background-image: radial-gradient(at bottom right, transparent, white); }
Implementations may optimize by not downloading and drawing images that are not visible (e.g., because they are behind other, fully opaque images).
2.4. Tiling Images: the background-repeat property
Name: | background-repeat |
---|---|
Value: | <repeat-style># |
Initial: | repeat |
Applies to: | all elements |
Inherited: | no |
Percentages: | N/A |
Computed value: | list, each item a pair of keywords, one per dimension |
Canonical order: | per grammar |
Animation type: | discrete |
Tests
- discrete-no-interpolation.html (live test) (source)
- background-repeat-round-1a.html (live test) (source)
- background-repeat-round-1b.html (live test) (source)
- background-repeat-round-1c.html (live test) (source)
- background-repeat-round-1d.html (live test) (source)
- background-repeat-round-1e.html (live test) (source)
- background-repeat-round-2.html (live test) (source)
- background-repeat-round-3.html (live test) (source)
- background-repeat-round-4.html (live test) (source)
- background-repeat-space-10.html (live test) (source)
- background-repeat-space-1a.html (live test) (source)
- background-repeat-space-1b.html (live test) (source)
- background-repeat-space-1c.html (live test) (source)
- background-repeat-space-2.html (live test) (source)
- background-repeat-space-3.html (live test) (source)
- background-repeat-space-4.html (live test) (source)
- background-repeat-space-5.html (live test) (source)
- background-repeat-space-6.html (live test) (source)
- background-repeat-space-7.html (live test) (source)
- background-repeat-space-8.html (live test) (source)
- background-repeat-space-9.html (live test) (source)
- background-repeat-no-repeat.xht (live test) (source)
- background-repeat-repeat-x.xht (live test) (source)
- background-repeat-repeat-y.xht (live test) (source)
- background-repeat-round-roundup.xht (live test) (source)
- background-repeat-round.xht (live test) (source)
- background-repeat-space.xht (live test) (source)
- gradient-repeat-spaced-with-borders.html (live test) (source)
- inheritance.sub.html (live test) (source)
- background-repeat-computed.html (live test) (source)
- background-repeat-invalid.html (live test) (source)
- background-repeat-valid.html (live test) (source)
- subpixel-repeat-no-repeat-mix.html (live test) (source)
This property specifies how background images are tiled after they have been sized and positioned. The property’s value is given as a comma-separated list of <repeat-style> values where
<repeat-style> = repeat-x | repeat-y | [repeat | space | round | no-repeat]{1,2}
Single values for <repeat-style> have the following meanings:
- repeat-x
- Computes to repeat no-repeat.
- repeat-y
- Computes to no-repeat repeat.
- repeat
- Computes to repeat repeat.
- space
- Computes to space space
- round
- Computes to round round
- no-repeat
- Computes to no-repeat no-repeat
If a <repeat-style> value has two keywords, the first one applies to the horizontal axis, the second to the vertical one, as follows:
- repeat
- The image is repeated in this direction as often as needed to cover the background painting area.
- space
- The image is repeated as often as will fit within the background positioning area without being clipped, and then the images are spaced out to fill the area. The first and last images touch the edges of the area. If the background painting area is larger than the background positioning area, then the pattern repeats to fill the background painting area. The value of background-position for this direction is ignored unless there is not enough space for two copies of the image in this axis, in which case only one image is placed, and background-position determines its position in this axis.
- round
- The image is repeated as often as will fit within the background positioning area. If it doesn’t fit a whole number of times, it is rescaled so that it does. See the formula under background-size. If the background painting area is larger than the background positioning area, then the pattern repeats to fill the background painting area.
- no-repeat
- The image is placed once and not repeated in this direction.
Unless one of the two keywords is no-repeat, the whole background painting area will be tiled, i.e., not just one vertical strip and one horizontal strip.
body { background: white url("pendant.png"); background-repeat: repeat-y; background-position: center; }
body { background-image: url(dot.png) white; background-repeat: space }
See § 2.1 Layering Multiple Background Images for how background-repeat interacts with other comma-separated background properties to form each background image layer.
2.5. Affixing Images: the background-attachment property
Name: | background-attachment |
---|---|
Value: | <attachment># |
Initial: | scroll |
Applies to: | all elements |
Inherited: | no |
Percentages: | N/A |
Computed value: | list, each item the keyword as specified |
Canonical order: | per grammar |
Animation type: | discrete |
Tests
- discrete-no-interpolation.html (live test) (source)
- background-attachment-350.html (live test) (source)
- background-attachment-353.html (live test) (source)
- background-attachment-fixed-block-002.html (live test) (source)
- background-attachment-fixed-border-radius-offset.html (live test) (source)
- background-attachment-fixed-inline-002.html (live test) (source)
- background-attachment-fixed-inline-scrolled.html (live test) (source)
- background-attachment-fixed-inside-transform-1.html (live test) (source)
- background-attachment-local-block-002.html (live test) (source)
- background-attachment-local-hidden.html (live test) (source)
- attachment-local-clipping-color-1.html (live test) (source)
- attachment-local-clipping-color-2.html (live test) (source)
- attachment-local-clipping-color-3.html (live test) (source)
- attachment-local-clipping-color-4.html (live test) (source)
- attachment-local-clipping-color-5.html (live test) (source)
- attachment-local-clipping-color-6.html (live test) (source)
- attachment-local-clipping-image-1.html (live test) (source)
- attachment-local-clipping-image-2.html (live test) (source)
- attachment-local-clipping-image-3.html (live test) (source)
- attachment-local-clipping-image-4.html (live test) (source)
- attachment-local-clipping-image-5.html (live test) (source)
- attachment-local-clipping-image-6.html (live test) (source)
- attachment-local-positioning-2.html (live test) (source)
- attachment-local-positioning-3.html (live test) (source)
- attachment-local-positioning-4.html (live test) (source)
- attachment-local-positioning-5.html (live test) (source)
- attachment-scroll-positioning-1.html (live test) (source)
- background-attachment-margin-root-001.html (live test) (source)
- background-attachment-margin-root-002.html (live test) (source)
- inheritance.sub.html (live test) (source)
- local-attachment-content-box-scroll.html (live test) (source)
- background-attachment-computed.html (live test) (source)
- background-attachment-invalid.html (live test) (source)
- background-attachment-valid.html (live test) (source)
If background images are specified, this property specifies whether they are fixed with regard to the viewport (fixed) or scroll along with the box (scroll) or its contents (local). The property’s value is given as a comma-separated list of <attachment> keywords where
<attachment> = scroll | fixed | local
- fixed
-
The background is fixed with regard to the viewport.
In paged media where there is no viewport,
a fixed background is fixed with respect to
the page box
and therefore replicated on every page.
Note: There is only one viewport per view. Even if an box is a scroll container, a fixed background doesn’t move with the box.
- local
- The background is fixed with regard to the box’s contents: if the box has a scrolling mechanism, the background scrolls with the box’s contents, and the background painting area and background positioning area are relative to the scrollable overflow area of the box rather than to the border framing them. Because the scrollable overflow area does not include the border area, for scroll containers the border-box value of background-clip may be treated the same as padding-box.
- scroll
- The background is fixed with regard to the box itself and does not scroll with its contents. (It is effectively attached to the box’s border.)
Even if the image is fixed, it is still only visible when it is in the background painting area of the box or otherwise unclipped. (See § 2.11 Backgrounds of Special Elements for the cases when background images are not clipped.) Thus, unless the image is tiled, it may be invisible.
body { background: red url("pendant.gif"); background-repeat: repeat-y; background-attachment: fixed; }
Note: User agents that do not support fixed backgrounds (for example due to limitations of the hardware platform) will ignore declarations with the keyword fixed. For example:
body { /* For all UAs: */ background: white url(paper.png) scroll; /* For UAs that do fixed backgrounds: */ background: white url(ledger.png) fixed; } h1 { /* For all UAs: */ background: silver; /* For UAs that do fixed backgrounds: */ background: url(stripe.png) fixed, white url(ledger.png) fixed; }
See § 2.1 Layering Multiple Background Images for how background-attachment interacts with other comma-separated background properties to form each background image layer.
2.6. Positioning Images: the background-position property
Name: | background-position |
---|---|
Value: | <bg-position># |
Initial: | 0% 0% |
Applies to: | all elements |
Inherited: | no |
Percentages: | refer to size of background positioning area minus size of background image; see text |
Computed value: | list, each item a pair of offsets (horizontal and vertical) from the top left origin each given as a computed <length-percentage> value |
Canonical order: | per grammar |
Animation type: | repeatable list |
Tests
- background-position-interpolation.html (live test) (source)
- background-position-x-interpolation.html (live test) (source)
- background-position-y-interpolation.html (live test) (source)
- background-position-calc-minmax-001.html (live test) (source)
- background-position-negative-percentage-comparison-002.html (live test) (source)
- background-position-negative-percentage-comparison.html (live test) (source)
- background-position-three-four-values.html (live test) (source)
- background-position-xy-three-four-values-passthru.html (live test) (source)
- background-position-bottom-right-repeat-round.html (live test) (source)
- background-position-right-in-body.html (live test) (source)
- inheritance.sub.html (live test) (source)
- background-position-computed.html (live test) (source)
- background-position-invalid.html (live test) (source)
- background-position-valid.html (live test) (source)
- background-position-x-computed.html (live test) (source)
- background-position-x-invalid.html (live test) (source)
- background-position-x-valid.html (live test) (source)
- background-position-y-computed.html (live test) (source)
- background-position-y-invalid.html (live test) (source)
- background-position-y-valid.html (live test) (source)
If background images have been specified, this property specifies their initial position (after any resizing) within their corresponding background positioning area.
The property’s value is given as a comma-separated list of <bg-position> values where
<bg-position> = [ [ left | center | right | top | bottom | <length-percentage> ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ] | [ center | [ left | right ] <length-percentage>? ] && [ center | [ top | bottom ] <length-percentage>? ] ]
If only one value is specified, the second value is assumed to be center. If two values are given, a <length-percentage> as the first value represents the horizontal position (or offset) and a <length-percentage> as the second value represents the vertical position (or offset). The <length-percentage> values here represent an offset of the top left corner of the background image from the top left corner of the background positioning area.
Note: A pair of keywords can be reordered, while a combination of keyword and length or percentage cannot. So center left is valid while 50% left is not.
If three or four values are given, then each <length-percentage> represents an offset and must be preceded by a keyword, which specifies from which edge the offset is given. For example, background-position: bottom 10px right 20px represents a 10px vertical offset up from the bottom edge and a 20px horizontal offset leftward from the right edge. If three values are given, the missing offset is assumed to be zero.
Positive values represent an offset inward from the edge of the background positioning area. Negative values represent an offset outward from the edge of the background positioning area.
background-position: left 10px top 15px; /* 10px, 15px */ background-position: left top ; /* 0px, 0px */ background-position: 10px 15px; /* 10px, 15px */ background-position: left 15px; /* 0px, 15px */ background-position: 10px top ; /* 10px, 0px */ background-position: left top 15px; /* 0px, 15px */ background-position: left 10px top ; /* 10px, 0px */
- <percentage>
-
A percentage for the horizontal offset is relative to
(width of background positioning area - width of background image).
A percentage for the vertical offset is relative to
(height of background positioning area - height of background image),
where the size of the image is the size given by background-size.
For example, with a value pair of 0% 0%, the upper left corner of the image is aligned with the upper left corner of, usually, the box’s padding edge. A value pair of 100% 100% places the lower right corner of the image in the lower right corner of the area. With a value pair of 75% 50%, the point 75% across and 50% down the image is to be placed at the point 75% across and 50% down the area.
Diagram of the meaning of background-position: 75% 50%. - <length>
- A length value gives a fixed length as the offset. For example, with a value pair of 2cm 1cm, the upper left corner of the image is placed 2cm to the right and 1cm below the upper left corner of the background positioning area.
- top
- Computes to 0% for the vertical position if one or two values are given, otherwise specifies the top edge as the origin for the next offset.
- right
- Computes to 100% for the horizontal position if one or two values are given, otherwise specifies the right edge as the origin for the next offset.
- bottom
- Computes to 100% for the vertical position if one or two values are given, otherwise specifies the bottom edge as the origin for the next offset.
- left
- Computes to 0% for the horizontal position if one or two values are given, otherwise specifies the left edge as the origin for the next offset.
- center
- Computes to 50% (left 50%) for the horizontal position if the horizontal position is not otherwise specified, or 50% (top 50%) for the vertical position if it is.
body { background: url("banner.jpeg") right top } /* 100% 0% */ body { background: url("banner.jpeg") top center } /* 50% 0% */ body { background: url("banner.jpeg") center } /* 50% 50% */ body { background: url("banner.jpeg") bottom } /* 50% 100% */
body { background-image: url("logo.png"); background-attachment: fixed; background-position: 100% 100%; background-repeat: no-repeat; }
background-position: right 3em bottom 10px
See § 2.1 Layering Multiple Background Images for how background-position interacts with other comma-separated background properties to form each background image layer.
2.6.1. Serialization of background-position values
The specified value and computed value of the <bg-position> type serialize exactly as defined in [CSS-VALUES-4] for <position>. For 3-value productions (which are not valid in <position>), the specified value serialization is identical to the equivalent 4-value syntax except that the omitted offset remains omitted.
2.7. Painting Area: the background-clip property
Name: | background-clip |
---|---|
Value: | <visual-box># |
Initial: | border-box |
Applies to: | all elements |
Inherited: | no |
Percentages: | N/A |
Computed value: | list, each item a keyword as specified |
Canonical order: | per grammar |
Animation type: | repeatable list |
Tests
- discrete-no-interpolation.html (live test) (source)
- background-clip-001.html (live test) (source)
- background-clip-002.html (live test) (source)
- background-clip-003.html (live test) (source)
- background-clip-004.html (live test) (source)
- background-clip-005.html (live test) (source)
- background-clip-006.html (live test) (source)
- background-clip-007.html (live test) (source)
- background-clip-008.html (live test) (source)
- background-clip-009.html (live test) (source)
- background-clip-010.html (live test) (source)
- background-clip-color-repaint.html (live test) (source)
- background-clip-color.html (live test) (source)
- background-clip-content-box-001.html (live test) (source)
- background-clip-content-box-002.html (live test) (source)
- background-clip-padding-box-001.html (live test) (source)
- background-clip-padding-box-with-border-radius.html (live test) (source)
- clip-rounded-corner.html (live test) (source)
- clip-text-animated-text.html (live test) (source)
- clip-text-dynamic-2.html (live test) (source)
- clip-text-flex.html (live test) (source)
- clip-text-multi-line.html (live test) (source)
- background-clip_padding-box.html (live test) (source)
- background-paint-order-001.html (live test) (source)
- background-rounded-image-clip-001.html (live test) (source)
- background-rounded-image-clip-002.html (live test) (source)
- css3-background-clip-border-box.html (live test) (source)
- css3-background-clip-content-box.html (live test) (source)
- css3-background-clip-padding-box.html (live test) (source)
- css3-background-clip.html (live test) (source)
- inheritance.sub.html (live test) (source)
- local-attachment-content-box-scroll.html (live test) (source)
- background-clip-computed.html (live test) (source)
- background-clip-invalid.html (live test) (source)
- background-clip-valid.html (live test) (source)
Determines the background painting area, which determines the area within which the background is painted. Values have the following meanings:
- border-box
- The background is painted within (clipped to) the border box.
- padding-box
- The background is painted within (clipped to) the padding box.
- content-box
- The background is painted within (clipped to) the content box.
Note: The root element has a different background painting area and thus the background-clip property has no effect when specified on it. See § 2.11 Backgrounds of Special Elements.
Note: The background is always drawn behind the border, if any. See “Elaborate description of Stacking Contexts” in [CSS2] Appendix E.
See § 4.2 Corner Shaping for how border-radius affects the shape of the background painting area.
See § 2.1 Layering Multiple Background Images for how background-clip interacts with other comma-separated background properties to form each background image layer.
2.8. Positioning Area: the background-origin property
Name: | background-origin |
---|---|
Value: | <visual-box># |
Initial: | padding-box |
Applies to: | all elements |
Inherited: | no |
Percentages: | N/A |
Computed value: | list, each item a keyword as specified |
Canonical order: | per grammar |
Animation type: | repeatable list |
Tests
- discrete-no-interpolation.html (live test) (source)
- background-position-origin-interpolation.html (live test) (source)
- background-gradient-subpixel-fills-area.html (live test) (source)
- background-origin-001.html (live test) (source)
- background-origin-002.html (live test) (source)
- background-origin-003.html (live test) (source)
- background-origin-004.html (live test) (source)
- background-origin-005.html (live test) (source)
- background-origin-006.html (live test) (source)
- background-origin-007.html (live test) (source)
- background-origin-008.html (live test) (source)
- origin-border-box.html (live test) (source)
- origin-border-box_with_position.html (live test) (source)
- origin-border-box_with_radius.html (live test) (source)
- origin-border-box_with_size.html (live test) (source)
- origin-content-box.html (live test) (source)
- origin-content-box_with_position.html (live test) (source)
- origin-content-box_with_radius.html (live test) (source)
- origin-content-box_with_size.html (live test) (source)
- origin-padding-box.html (live test) (source)
- origin-padding-box_with_position.html (live test) (source)
- origin-padding-box_with_radius.html (live test) (source)
- origin-padding-box_with_size.html