SVG <g> Element (original) (raw)

Last Updated : 16 Jun, 2022

The SVG element is a container used to group other SVG elements.

Transformations applied to the element are also performed on its child elements, and its attributes are inherited by its children.

Syntax:

Attributes:

Example 1: Making green consecutive circles inheriting attributes from the element.

html `

`

Output:

Example 2: Making rectangles with the same inherited properties.

html `

    <g fill="white" stroke="url(#gfgStr)" stroke-width="15">
        <rect width="400" height="200" />
        <rect width="200" height="200" />
        <rect width="200" height="100" />
    </g>
</svg>

`

Output:

Browsers Supported: The following browsers are supported by this SVG element: