g
The g
SVG element is a container used to group other SVG elements.
Transformations applied to the g
element are performed on its child elements, and its attributes are inherited by its children. It can also group multiple elements to be referenced later with the use
element.
This element only includes global attributes
Usually, this element is created with:
const g = parentElement.add('g')
It's possible to create it as a disconnected element with gSVG('g')
and attach it to the SVG document with .attachTo()
.
Parent elements: a | defs | g | marker | mask | pattern | svg | switch | symbol.
Child elements: a | animate | animateMotion | animateTransform | circle | clipPath | defs | desc | ellipse | filter | foreignObject | g | image | line | linearGradient | marker | mask | metadata | mpath | path | pattern | polygon | polyline | radialGradient | rect | set | stop | style | svg | switch | symbol | text | title | use | view.