HTML Academy
Challenge: Pyramids
An Introduction to SVG8/15
Back to the list of tasks
  • 1. Hello, SVG!
  • 2. Drawing a Rectangle
  • 3. Rectangle Coordinates
  • 4. Corner Rounding
  • 5. Challenge: Fixing the TV
  • 6. Polygons
  • 7. Challenge: Pyramids
  • 8. Drawing a Circle
  • 9. Challenge: Target
  • 10. Drawing an Ellipse
  • 11. Challenge: Surprised Smiley
  • 12. Drawing Lines
  • 13. Challenge: Arithmetic Operators
  • 14. Drawing Polylines
  • 15. Challenge: Hot-Air Balloons
Challenge: Target
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Drawing a Circle

The circle is drawn using the circle tag. Code example:

<circle r="50"/>

The r attribute determines the radius of the circle.

Unlike the previous shapes we covered, the position of the circle in space is determined by the coordinates of the center of the shape: the cx attribute is used to set the position along the horizontal axis, and cy is used to set the position along the vertical axis.

By default, the circle’s center coordinates are 0.0, so it is located in the upper left corner. Move the shape:

<circle r="50" cx="100" cy="50%"/>

Values can be specified either using pixels or percentages. Percentages are calculated relative to the dimensions of the SVG element.

The radius and coordinates can only be specified using attributes, and you cannot do this using CSS.

Comments

  • object.svg
  • style.css
SVG
<svg> </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. Draw a circle with a radius of 10 and a center (cx) with a horizontal axis offset of 50, a vertical axis (cy) offset of 50%, and a fill color of crimson.
    2. Draw a second circle with the following properties: radius – 30,cx = 105,cy = 50%, fill color – orangered.
    3. And finally draw a third circle with the properties: radius — 50, cx = 200 and  cy = 50%, fill color — gold.

    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.