Interactive online courses HTML Academy
2026-03-09 14:05 Diff

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Stroke Opacity

The opacity is set using the stroke-opacity property with values ranging from 0 to 1, for example: stroke-opacity = "0.5".

Or via CSS:

rect { stroke-opacity: 0.5; }

Comments

  • object.svg
  • style.css

SVG

<svg width="300" height="150"> <circle r="50" cx="75" cy="75" fill="none" stroke="darkorange" stroke-width="40"></circle> <circle r="50" cx="150" cy="75" fill="none" stroke="gold" stroke-width="40"></circle> <circle class="shape-stroke" r="50" cx="225" cy="75" fill="none" stroke="lightseagreen" stroke-width="40"></circle> </svg>

CSS

svg { border: 1px solid #dddddd; }

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%

  1. Use the attribute to assign a stroke opacity value of 0.7 to the first shape,
  2. and then assign an opacity value of 0.6 to the second shape.
  3. In the CSS, set the opacity of the stroke to 0.5 for the third shape.