HTML Academy
Previous task
Designing SVG Shapes1/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
Fill Opacity
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Fills

In the section about shapes, you already were able to learn a little about the design capabilities of vector shapes. Now we will consider this issue in a little more detail.

SVG shapes have a rich range of design options: they, just like HTML elements, can be filled with a color, gradient, or image. But in addition to this, you can also separately control the opacity of the fill and stroke, and you can also fill elements with text, for example.

There are also interesting options for strokes. For example, you can control the appearance of a dashed stroke by substituting dots, dashes, or even morse code, and you can also style a stroke not only with color, but also with a gradient or image.

Let’s start with fills. Unless some other color is specified, the shape is filled with black by default:

<circle r="60" cx="150" cy="50%"></circle>

The fill color is set using the fill attribute:

<circle r="60" cx="150" cy="50%" fill="gold"></circle>

or a similar property in CSS:

circle {
  fill: gold;
}

The result will be the same:

The color can be set using whatever format is convenient.

Comments

  • object.svg
  • style.css
SVG
<svg width="300" height="150"> <circle r="60" cx="75" cy="50%"></circle> <circle r="60" cx="150" cy="50%"></circle> <circle class="shape-fill" r="60" cx="225" cy="50%"></circle> </svg>
CSS
svg { border: 1px solid #dddddd; } .shape-fill { }

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. Specify a fill for the first shape with an attribute in the HEX format: fill="#ff7700".
    2. And assign an attribute in the HSLA format for the second shape: fill="hsla(50, 100%, 50%, 0.75)".
    3. For the third shape, assign a fill by specifying the name of the color fill: yellowgreen in the CSS editor.

    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.