HTML Academy
Life Saver, Part 4
Designing SVG Shapes19/20
Back to the list of tasks
  • 1. Fills
  • 2. Fill Opacity
  • 3. No Fill
  • 4. Challenge: Colorful Squares
  • 5. Strokes
  • 6. Stroke Width
  • 7. Stroke Opacity
  • 8. Challenge: Stroke Width and Transparency
  • 9. Line Ends
  • 10. Bend Type
  • 11. Challenge: Zigzags
  • 12. Dashed Lines, Part 1
  • 13. Dashed Lines, Part 2
  • 14. Challenge: Sunrise
  • 15. Life Saver, Part 1
  • 16. Life Saver, Part 2
  • 17. Life Saver, Part 3
  • 18. Life Saver, Part 4
  • 19. Stroke Offset
  • 20. Challenge: Lollypop
Challenge: Lollypop
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Stroke Offset

You can offset a dashed stroke using the stroke-dashoffset attribute. Take the following example:

stroke-dasharray="50"

and add stroke-dashoffset: stroke-dasharray="50" stroke-dashoffset="25"

The dashes in the stroke have moved counterclockwise by the specified amount. The stroke-dashoffset value can be negative, which will make the stroke move clockwise.

The stroke-dashoffset CSS property works similarly.

Comments

  • object.svg
  • style.css
SVG
<svg width="200" height="200"> <circle r="70" cx="100" cy="100" fill="none" stroke="lightgrey" stroke-width="55"></circle> <circle r="70" cx="100" cy="100" fill="none" stroke="tomato" stroke-width="50"></circle> <circle r="70" cx="100" cy="100" fill="none" stroke="white" stroke-width="50" stroke-dasharray="20 90"></circle> </svg>
CSS
svg { border: 1px solid #dddddd; }

What didn’t you like in this task?

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%
Goalscompleted
0
    1. Add the attribute stroke-dashoffset = "10" to the last circle to align the white lines on the life saver.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.