Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML SVG Basics SVG and CSS Responsive SVGs

Why not just apply the star-point class to a <g> SVG element container?

I may be jumping ahead here, but after completing a few courses here at Treehouse, I now become weary when I see a lot of copying and pasting! DRY!!

Rather than copy and paste the same .star-point class ten times to each of the latter circle elements, why not just wrap them inside a <g> SVG element container, and apply the class to that?

e.g.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Scalable Vector Graphics</title>
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/main.css">
  </head>
  <body>

    <h1>SVG Example</h1>

    <div class="wrapper">

        <svg class="graphic" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" enable-background="new 0 0 360 360">
          <path fill="#8361B4" d="M0 0h360v360h-360z" />
          <circle class="outer-circle" fill="#FDE135" stroke="#fff" stroke-width="8" stroke-miterlimit="10" cx="180" cy="180" r="157" />
          <circle class="inner-circle" fill="#CAA61F" stroke="#fff" stroke-width="8" stroke-miterlimit="10" cx="180" cy="180" r="108.3" />
          <path class="star" d="M89.4 276.7c-26-24.2-42.2-58.8-42.2-97.1 0-22.6 5.6-43.8 15.5-62.4m234.7.1c9.9 18.6 15.4 39.7 15.4 62.2 0 38.3-16.2 72.8-42.1 97" stroke="#CAA61F" stroke-width="8" stroke-linecap="round" stroke-miterlimit="10" fill="none" />
          <path class="outer-circle" fill="#FDE135" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="M180 107.8l16.9 52.1h54.8l-44.3 32.2 16.9 52.1-44.3-32.2-44.3 32.2 16.9-52.1-44.3-32.2h54.8z" />
          <g class="star-point">
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="180" cy="107.8" r="4.4" />
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="223.7" cy="244.2" r="4.4" />
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="135.5" cy="244.2" r="4.4" />
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="108.3" cy="160.4" r="4.4" />
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="251.7" cy="160.4" r="4.4" />
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="197.4" cy="159.4" r="4.4" />
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="163" cy="159.4" r="4.4" />
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="152" cy="192.5" r="4.4" />
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="208" cy="192.5" r="4.4" />
            <circle fill="#CAA61F" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"stroke-miterlimit="10" cx="180" cy="213.2" r="4.4" />
          </g>
        </svg>

    </div>

  </body>
</html>