Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of g tag?

Tags:

svg

I am new to svg, as far as I saw everywhere they using svg elements within g tag, is there any particular reason for using svg elements within g tag other than applying transformation for whole set of elements?

like image 497
Abinaya Selvaraju Avatar asked Jun 27 '13 11:06

Abinaya Selvaraju


2 Answers

That's a pretty important and useful reason. But other reasons you might do it are so you can:

  • apply the same styling (eg. fill="blue") to a set of elements,
  • reference to the group of objects from a use.

Not to mention the simple organisational reasons.

like image 91
Paul LeBeau Avatar answered Oct 19 '22 09:10

Paul LeBeau


http://tutorials.jenkov.com/svg/g-element.html says:

The <g> element is used to group SVG shapes together. Once grouped you can transform the whole group of shapes as if it was a single shape. This is an advantage compared to a nested <svg> element which cannot be the target of transformation by itself.

like image 14
Uooo Avatar answered Oct 19 '22 09:10

Uooo