Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsCSS masks control which parts of an element show and how opaque they are. Use mask-image with a gradient, image, or SVG mask: opaque mask areas reveal the element, transparent areas hide it, and partial opacity creates a soft transition. For a sharp, all-or-nothing shape, clip-path is usually simpler.
How CSS masking works
A mask is applied to an element’s rendered appearance. In alpha mode, the mask’s transparency determines visibility: fully opaque areas reveal the element, fully transparent areas hide it, and intermediate alpha values partially reveal it. The mask’s color is irrelevant in alpha mode. MDN’s introduction to CSS masking explains the model and its available source types.
As an Amazon Associate I earn from qualifying purchases.
A mask source can be a CSS gradient, a raster image such as PNG or JPEG, or an SVG <mask>. Choose the source based on the effect: gradients are convenient for fades, image transparency can define a silhouette, and SVG can provide authored mask artwork.
Use a gradient mask for a fade
This example fades an image out at its lower edge. The gradient is opaque through 70% of the height and transitions to transparent at the bottom.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
.fade-image {
mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
mask-mode: alpha;
}
In alpha mode, black and any other fully opaque color reveal the element; transparency hides it. Use mask-mode: alpha explicitly when you want the gradient’s opacity—not its brightness—to determine the result.
Choose alpha or luminance mode
Alpha and luminance are two ways to turn a source into mask opacity. Alpha uses the source’s transparency. Luminance uses its brightness together with its alpha, so brighter pixels reveal more and darker pixels hide more. This makes luminance useful for a fully opaque grayscale source, such as white artwork on black.
The default match-source typically resolves to alpha for image sources, but an SVG <mask> defaults to luminance unless configured otherwise. If the distinction affects the design, set the mode deliberately with CSS mask-mode or the SVG mask’s mask-type. See MDN’s mask-image reference for source behavior and details.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchUse a raster image or SVG mask
Raster image with transparency
A PNG with transparent and opaque pixels can define a mask silhouette using its alpha channel. Point mask-image at the image and set mask-mode: alpha when alpha behavior needs to be unambiguous. Make sure the image is reachable from the page and served from an allowed origin.
SVG mask
An SVG mask may be referenced through an external SVG or an inline fragment. For an inline fragment, the mask source is a URL fragment such as url(#my-mask); the referenced SVG must define an element with that ID. Check the source’s mask type: SVG masks default to luminance unless you configure alpha behavior, so a mask that looks correct as artwork may produce an unexpected result under a different mode.
Mask images are subject to HTTP/HTTPS and CORS-related restrictions, and local file:// sources are not accepted as image values. If an image source is missing or unsupported, it behaves like transparent black, which can make the masked element disappear.
Rank #3
Masking versus clip-path
Use clip-path when the effect is a simple hard-edged shape: each point is either visible or hidden. Use masking when you need soft edges, partial transparency, brightness-driven visibility, or combined visual masks. MDN notes: “While masking provides more control and options, clipping can perform better if a basic shape is all that’s required — they are easier to interpolate.” See MDN’s CSS masking guide for the distinction.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Both techniques affect rendering after the element’s base styles are applied. MDN describes the effect order as filters, clipping, masking, then opacity. Prefer the simpler clipping approach when it expresses the design; use a mask when the extra control is needed.
Size, position, repeat, and combine mask layers
A mask layer can be adjusted with properties including mask-size, mask-position, and mask-repeat. Multiple sources can be supplied as comma-separated layers. Their order matters, especially when using compositing: the operator determines how one layer combines with another.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
The mask-composite operators are add, subtract, intersect, and exclude. A none entry still occupies a layer position, which matters when matching comma-separated layer properties. Keep the source and property lists aligned, and verify the visual result when changing layer order or operator. The MDN mask-properties guide and mask-composite reference cover these controls.
Compatibility and production checks
MDN marks mask-image widely available and says it has been available across browsers since December 2023. That summary does not mean every mask-* subproperty or edge case behaves identically in every target browser. Check compatibility for the exact properties you use and test the actual browsers your site supports. MDN’s compatibility data is the place to verify the current status.
Troubleshoot a mask that is not showing
- The entire element disappears: confirm the mask URL or SVG fragment resolves and the source loads. A missing or unsupported mask image behaves like transparent black.
- A grayscale SVG has the opposite or unexpected effect: check whether the source is using luminance. SVG
<mask>sources default to luminance unless configured otherwise; setmask-modeormask-typeto match the intended behavior. - A transparent image reveals the wrong areas: verify that the source has the intended alpha channel and that alpha mode is selected when transparency should control visibility.
- An external mask fails to load: check that it is served over HTTP or HTTPS and that cross-origin access permits its use. A local
file://path is not a supported image source. - Multiple layers combine unexpectedly: inspect comma-separated layer ordering, make sure related property lists align, and check the chosen
mask-compositeoperator. Remember thatnonestill takes a layer position. - It differs between browsers: check support for each masking property used, not only
mask-image, and test the specific browsers and versions you need to support.
Or skip the browser setup
If you need a screenshot of the finished page to check the mask, ScreenshotNeo can capture a URL with one GET request. Cookie banners are accepted and removed, along with known newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the page verdict and billing status in headers. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf.
For a WebP screenshot, replace the example URL with your page and use your API key:
Best Value
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.
Frequently Asked Questions
Does a CSS mask change the element’s layout size?
No. A mask changes which rendered parts are visible; it does not define the element’s layout dimensions.
Can I use CSS masking without an image file?
Yes. A CSS gradient can be the mask source, so a fade does not require a separate image asset.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




