Interactive online courses HTML Academy
2026-03-09 10:48 Diff

You can control the opacity of the fill with the property fill-opacity. The opacity can also be set either using the attribute or via CSS.

The value is specified as a number from 0 to 1, such as, for example:

<rect width="150" height="100" fill="gold" fill-opacity="0.5"></rect>rect { fill: gold; fill-opacity: 0.5; }

Opacity works for all types of fills, including gradients and patterns: