← Files Modern Web GuidanceARCHIVED FILE
skills/modern-web-guidance/guides/visual-design/soft-edge-content-fade.md
2.6 KB · Oct 5, 2026 · 18:34 UTC
# Soft Edge Content Fade
## Overview
To apply a transparency gradient to the edges of a container (e.g., to indicate more content is available to scroll or to fade out text), use CSS Masking with a linear gradient. This approach is superior to using a semi-transparent overlay because it actually fades the content itself, allowing the background to show through naturally without interfering with text selection or pointer events.
## Implementation
To implement a soft edge fade:
### Fading the bottom edge of a container
This is useful for indicating that there is more content below in a scrollable area.
```css
.container {
/* Enable scrolling */
overflow-y: auto;
/* MANDATORY: Use vendor prefix for wider support in older browsers */
-webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
/* Standard property for modern browsers */
mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}
```
### Fading both top and bottom edges
You can use a single gradient with multiple color stops to fade both edges.
```css
.dual-fade-container {
/* Content is visible between 10% and 90% of the height */
-webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%);
mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%);
}
```
## Fallback strategies
Baseline status for Masks: Widely available. It's been Baseline since 2023-12-07.
Supported by: Chrome 120 (Dec 2023), Edge 120 (Dec 2023), Firefox 53 (Apr 2017), and Safari 15.4 (Mar 2022).
If a browser does not support `mask-image` or the prefixed version:
- The content will not fade and will display with sharp edges.
- Ensure the interface is still functional and content is readable without the fade (progressive enhancement).
- You can use a semi-transparent overlay as a fallback, but be aware it requires knowing the background color and may interfere with text selection unless `pointer-events: none` is used.
```css
/* Fallback using an overlay for browsers that do not support masking */
@supports (not (mask-image: linear-gradient(to bottom, black, transparent))) and (not (-webkit-mask-image: linear-gradient(to bottom, black, transparent))) {
.container {
position: relative;
}
.container::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 20%;
/* Fallback assumes a solid background color (e.g., white) */
background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
pointer-events: none; /* Allow interaction with text underneath */
}
}
```
SHA-256: f9a4607b1e34c271afe47085bea7d0d6fdc00a85fa7b93bb123cd4a99286b17b