Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6198955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:06:15+00:00 2026-05-24T04:06:15+00:00

So I have a <g> element with some <rect>s inside it, they all have

  • 0

So I have a <g> element with some <rect>s inside it, they all have same fill color, but can be of different sizes. I want to reuse the <g>, but fill it with a different color, is it possible?

I can change the markup any way I like.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:06:15+00:00Added an answer on May 24, 2026 at 4:06 am

    You can define the rect group using <defs> like so:

    <defs>
        <g id="rect-group">
            <rect x="0" y="0" width="60" height="30"/>
            <rect x="20" y="10" width="20" height="50"/>
        </g>
    </defs>
    

    Then you can use this group multiple times, putting it in different places with with transform if you like:

    <g class="group-1" transform="translate(10.5,20.5)">
        <use xlink:href="#rect-group" />
    </g>
    
    <g class="group-2" transform="translate(55.5,32.5)">
        <use xlink:href="#rect-group" />
    </g>
    

    You can style these groups directly or give them different classes as above and use CSS to style as you like:

      <style> 
        .group-1{
            fill: red;
            stroke: white;
        }
        .group-2{
            fill: blue;
            stroke: black;
        }
      </style>
    

    For an example, see: http://dl.dropbox.com/u/169269/rect_group.svg

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some element in my container and want to save all properties of
If I have some array element, how can I get individual numbers from the
So I have an element that is placed directly inside body: <body> <div id=header>Some
I have a div element containing some text. When the user clicks a word
Suppose I have an element on my page with id some_id. I want to
I have HTML page with some HTML element with ID=logo . I need to
I have some AJAX work that brings across an additional form element that I
I have xml where some of the element values are unicode characters. Is it
I have a Zend_Form_Element_Multicheckbox and I want to put some of its elements in
I have this in some WSDL: <element name="startDate" type="xsd:dateTime"/> <element name="endDate" type="xsd:dateTime"/> Which results

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.