HTML Academy
Challenge: Stroke Width and Transparency
Designing SVG Shapes9/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
Bend Type
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Line Ends

In SVG, you can specify how the stroke at the end of lines behaves using the attribute stroke-linecap. In the examples below, we have added auxiliary bright lines with strokes and shown the possible values of stroke-linecap:

1. butt is the default value. When this value is set, the stroke simply ends at the ends of the line:

2. round, when this value is set, the stroke is evenly rounded around the ends of the line:

3. square, when this value is set, an additional stroke with rectangular edges is added around the ends of the line:

In CSS, the appearance of strokes where the lines bend can be controlled using the similar property stroke-linejoin.

Comments

  • object.svg
  • style.css
SVG
<svg width="300" height="300"> <line x1="40" y1="50" x2="260" y2="50" stroke-width="50" stroke="tomato" stroke-linecap="butt"></line> <line x1="40" y1="150" x2="260" y2="150" stroke-width="50" stroke="gold"></line> <line class="shape-linecap" x1="40" y1="250" x2="260" y2="250" stroke-width="50" stroke="lightseagreen"></line> </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. Assign the attribute stroke-linecap="round" to the second line.
    2. In the CSS, assign the value square to the stroke-linecap property for the third line.

    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.