CSS Portal

CSS stop-opacity Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The stop-opacity CSS property controls the transparency of an individual color stop inside an SVG gradient. It is applied to the elements within gradient definitions (for example, inside or ) and affects how much of that stop's color contributes to the painted gradient at that position. Because it targets a single stop, it lets you shape the visual softness and translucency of a gradient's transitions without changing the stop's hue.

When a gradient is rendered the alpha from the stop's color is combined with the stop-color specification for that stop to produce the final premultiplied color used during compositing. This means adjusting stop-opacity can make a stop appear more washed-out or more solid even if the color itself remains the same, and it changes how that stop blends with neighboring stops and underlying content. Using it in concert with the color at that stop gives fine-grained control over subtle visual effects like soft fades or partially transparent bands.

The effect of stop-opacity is also influenced by any object-level opacity applied to the element that uses the gradient. For example, an overall opacity on the shape painted with the gradient or per-channel properties such as fill-opacity and stroke-opacity will further modulate the ultimately visible transparency—those are applied at the paint/compositing stage and can make a gradient appear more or less transparent as a whole versus altering individual stops. Understanding this layering is important when you need predictable blending results.

stop-opacity is useful for animations and dynamic effects: you can animate it to fade individual stops in or out, creating moving transparency bands or smoothly adjusting a gradient’s strength. It can be set through inline presentation attributes on elements or via CSS rules targeting those stops, and is commonly used together with CSS transitions or keyframe animations to produce time-based changes. In practice, designers often combine subtle changes to both color and stop opacity to achieve polished gradient transitions that remain visually consistent across different backgrounds.

Definition

Initial value
1
Applies to
<stop> elements in <svg>
Inherited
no
Computed value
as specified
Animatable
yes
JavaScript syntax
object.style.stopOpacity

Syntax

stop-opacity = <alphavalue> | inherit

Values

  • <number>A numeric value between 0 and 1
  • <percentage>A percentage value between 0% and 100%

Example

<div class='example'>
<svg width='400' height='150' viewBox='0 0 400 150' xmlns='http://www.w3.org/2000/svg' role='img' aria-label='Gradient with stop-opacity set by CSS'>
<defs>
<linearGradient id='grad' x1='0%' y1='0%' x2='100%' y2='0%'>
<stop offset='0%' class='stop-start'/>
<stop offset='100%' class='stop-end'/>
</linearGradient>
</defs>

<rect x='10' y='10' width='380' height='60' fill='url(#grad)' stroke='#000' stroke-width='1'/>
<rect x='10' y='80' width='180' height='60' fill='url(#grad)' stroke='#000' stroke-width='1'/>
<circle cx='300' cy='110' r='30' fill='url(#grad)' stroke='#000' stroke-width='1'/>
</svg>
</div>
/* Container sizing */
.example {
    width: 400px;
    max-width: 100%;
}

/* Style the gradient stops via CSS using stop-opacity */
.stop-start {
    stop-color: #ff7f50;    /* coral */
    stop-opacity: 1;         /* fully opaque */
}

.stop-end {
    stop-color: #1e90ff;    /* dodgerblue */
    stop-opacity: 0.25;      /* mostly transparent */
}

/* Optional: make the SVG render as a block and keep sharp edges */
svg {
    display: block;
}

/* Example interactive change: increase end opacity on hover */
.example:hover .stop-end {
    stop-opacity: 0.9;
}

Browser Support

The following information will show you the current browser support for the CSS stop-opacity property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!