Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

flood-opacity — SVG filter color opacity

The flood-opacity property controls the opacity of the color generated by feFlood and the shadow color of feDropShadow in SVG filters.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

flood-opacity: <'opacity'>;
flood-opacity: 0.5;
flood-opacity: 50%;

flood-opacity applies to feFlood and feDropShadow elements. Its initial value is 1; it is not inherited. It is also available as an SVG presentation attribute.

It accepts the syntax of opacity: a number or percentage. 0 means fully transparent, while 1 or 100% means fully opaque. The computed value is clamped to [0,1].

The alpha of flood-color is multiplied by flood-opacity: 0.5 × 0.5 produces 0.25. Do not confuse this property with opacity, which controls the opacity of the whole element. The example shows a blue fill at 50% opacity over white.

Examples

<!doctype html>
<meta charset="utf-8">
<title>flood-opacity</title>
<style>
  #wash { flood-color: blue; flood-opacity: 0.5; }
  svg { background: white; }
</style>
<svg xmlns="http://www.w3.org/2000/svg" width="160" height="80" viewBox="0 0 160 80">
  <defs>
    <filter id="f" x="0" y="0" width="1" height="1">
      <feFlood id="wash" />
    </filter>
  </defs>
  <rect width="160" height="80" filter="url(#f)" />
</svg>

Result

A 160 × 80 rectangle of blue at 50% opacity over a white background.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources