CSS Masking, Clipping, Compositing, and Blending
Learn how CSS controls painted visibility and how clipping, masking, compositing, and blending change the pixels produced from already-laid-out content without replacing layout ownership.
Advanced
This lesson explains how CSS changes which already-rendered pixels remain visible and how colors from overlapping elements are combined. The key distinction is between layout geometry and the later visual operations that affect painting and compositing.
Clipping establishes a hard geometric boundary. Masking uses alpha or luminance information to control visibility. Blending changes how colors interact where an element is composited with its backdrop. These mechanisms can be combined, but they do not become a new layout system.
This lesson is the primary Foxipa owner for CSS Masking and the CSS Compositing and Blending model. It does not take ownership of box layout, overflow/scrolling, Shapes wrapping geometry, transforms, background painting, or accessibility semantics.
Layout first, visual operations later
A box is laid out before clipping, masking, and blending alter its final visible pixels. A visual effect therefore does not make the element participate in a different layout algorithm.
Output
Ready to run.
Quick check
Which stage owns the element’s size and position?
Hard clipping with clip-path
clip-path removes pixels outside a geometric clipping path. The clipped pixels are not painted as visible output, but the element keeps its layout geometry.
Output
Ready to run.
Quick check
What does clip-path primarily change?
Basic clip-path shapes
The basic shape functions used by clip-path describe geometry such as circle(), ellipse(), inset(), and polygon(). Their coordinates are interpreted against a reference box rather than creating new layout boxes.
Output
Ready to run.
Quick check
Do basic shapes create extra layout boxes?
Reference boxes matter
A clipping path can use a reference box such as border-box or padding-box. Changing that reference changes the coordinate space of the same shape function without changing the element’s layout algorithm.
Output
Ready to run.
Quick check
What does a reference box provide?
Clipping is not overflow
Overflow clipping and clip-path are related visual boundaries but have different owners. Overflow handles overflow behavior and scrollable/clipping mechanics; clip-path applies an explicit clipping path to the rendered element.
Output
Ready to run.
Quick check
Which property owns scrollable overflow behavior?
.outer{width:12rem;:clip;border:2px solid;padding:1rem}.inner{width:20rem;height:4rem;background:#999;clip-path:inset(0 25% 0 0)}
Masking controls visibility continuously
A mask supplies visibility information rather than only a yes/no geometric boundary. Depending on the mask source and mode, pixels can be partially transparent.
Output
Ready to run.
Quick check
What makes masking different from a simple hard clip?
Alpha masks
An alpha mask derives visibility from alpha information. Opaque mask regions preserve the element, transparent regions hide it, and intermediate alpha can produce partial visibility.
Output
Ready to run.
Quick check
What does alpha represent in an alpha mask?
Luminance masks
A luminance mask can derive visibility from the perceived brightness of the mask source rather than simply treating its color as alpha. The mask mode determines how the source contributes to visibility.
Output
Ready to run.
Quick check
What controls whether a mask source is interpreted through alpha or luminance?
Mask layers
Masking supports layered sources. Like other layered CSS image values, the order and repetition of mask layers matter; the mask composite model then determines how layers combine.
Output
Ready to run.
Quick check
Can masking have multiple mask-image layers?
Mask sizing and positioning
Mask layers have their own sizing, position, repeat, origin, and clip controls. These determine how a mask source is mapped to the element’s mask reference area; they do not resize the element’s layout box.
Output
Ready to run.
Quick check
Does mask-size resize the element itself?
Clip versus mask
Use clipping when the desired visibility boundary is a hard geometric path. Use masking when visibility needs alpha/luminance variation or image-derived transparency.
Output
Ready to run.
Quick check
Which tool naturally supports partial transparency?
Blend modes change color interaction
A blend mode defines how source and backdrop colors are mathematically combined where they overlap. It is different from opacity: opacity changes contribution, while blending changes the color-combination operation.
Output
Ready to run.
Quick check
What does mix-blend-mode primarily control?
Opacity is not a blend mode
Opacity controls how strongly the composited result contributes to the backdrop. A blend mode selects the color-combination operation; the two concepts can be used together but are not interchangeable.
Output
Ready to run.
Quick check
Which mechanism selects a color-combination formula?
Isolation creates a compositing boundary
isolation: isolate establishes a new stacking/compositing context for blending purposes so descendants can blend with the isolated group rather than unexpectedly reaching through it to the outside backdrop.
Output
Ready to run.
Quick check
What is isolation for?
Source and backdrop
Blending is easiest to reason about as two roles: a source being composited and the backdrop behind it. The blend function combines their colors before the compositing operation produces the visible result.
Output
Ready to run.
Quick check
In a blend operation, what is the backdrop?
Clipping does not change layout
After clipping, the element still occupies the layout space established by its layout algorithm. A clipped visual may appear smaller or differently shaped without causing surrounding content to reflow around the visible pixels.
Output
Ready to run.
Quick check
Does clip-path make the neighboring flex item move into the clipped-away area?
Transforms and visual effects
Transforms can alter the coordinate space and visual geometry of an element, while clipping and masking determine visible pixels within their respective processing model. This lesson does not redefine transform composition.
Output
Ready to run.
Quick check
Which lesson owns transform-function composition?
Shapes and clipping are different
shape-outside changes the geometry used by inline content wrapping around a float. clip-path changes which pixels of the element remain visible. The two can appear together but solve different problems.
Output
Ready to run.
Quick check
Which property controls text wrapping geometry here?
.wrap{max-width:22rem}.float{float:left;width:8rem;height:8rem;margin:.5rem 1rem .5rem 0;:circle(50%);clip-path:circle(42%);background:#888}.wrap p{line-height:1.6}
Masks and images
Mask sources can use image values, but the Images owner remains responsible for the general CSS image-value model. This lesson focuses on how an image is consumed as a mask, not on every image function.
Output
Ready to run.
Quick check
Who owns the general CSS <image> value model?
Clip paths and border radii
A border radius shapes the background and border painting of a box according to the Backgrounds and Borders model. clip-path is a separate clipping mechanism and should not be taught as merely another spelling of rounded corners.
Output
Ready to run.
Quick check
Which owner defines border-radius painting?
Debugging the rendering stage
When an effect looks wrong, first identify whether the problem is layout geometry, clipping geometry, mask mapping, or color compositing. Inspect one mechanism at a time instead of changing unrelated layout properties.
Output
Ready to run.
Quick check
What should you isolate first when debugging a visual effect?
Reduced motion is not a masking rule
User-preference features can change whether an author applies an animation or transition, but masking and blending themselves do not become preference semantics. Keep preference evaluation with Media Features / User Preferences.
Output
Ready to run.
Quick check
Where does prefers-reduced-motion belong?
Status and implementation-sensitive features
CSS Masking Level 1 and Compositing and Blending Level 1 are Candidate Recommendation Drafts in current W3C publication material. Treat the core model as standards-based while checking implementation-sensitive details and newer extensions against current specifications.
Output
Ready to run.
Quick check
How should developing or implementation-sensitive extensions be taught?
The ownership decision tree
Ask three questions: does the feature decide where boxes participate in layout, which pixels survive, or how surviving colors combine? Layout owners answer the first, Masking/Clipping answers the second, and Compositing/Blending answers the third.
Output
Ready to run.
Quick check
Which question identifies the compositing/blending owner?
A reusable mental model
Remember the sequence: layout establishes boxes; overflow can clip overflow; visual clipping can apply a clip path; masking controls visibility; compositing combines the result with a backdrop; blending can alter the color-combination step.
Quick check
What should happen before visual clipping is considered?
What this lesson does not own
Do not move Flexbox, Grid, Flow, Sizing, Shapes, Transforms, Backgrounds, Images, Color, or Overflow concepts into this lesson merely because a visual effect appears alongside them.
Quick check
Which rule prevents this lesson from duplicating other CSS domains?
A practical debugging order
Freeze layout first. Then test clipping. Then test mask source and mapping. Finally test blend mode and isolation. This order reduces the chance that one visual symptom is mistaken for a layout bug.
Quick check
What is the recommended debugging order?
Core properties, one model
clip-path handles geometric clipping; mask-* handles visibility through mask sources and mapping; mix-blend-mode controls color blending with the backdrop; isolation controls the compositing boundary. They are related, but they are not interchangeable.
Quick check
Which property family handles visibility through a mask?
.status{width:18rem;height:6rem;padding:1rem;clip-path:inset(8% round 1rem);image:linear-gradient(90deg,#000,transparent);background:#888}
Final check
If you can explain whether a problem changes layout, visibility, or color combination—and name the existing Foxipa owner for that stage—you can place most masking, clipping, and blending problems without creating a duplicate curriculum owner.
Quick check
What is the final ownership test?
Thanks for your feedback.
Mark this learning resource complete to track your learning progress.