Back to Content

Index

files/en-us/web/svg/reference/element/g/index.md

latest967 B
Original Source

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 {{SVGElement("use")}} element.

Usage context

{{svginfo}}

Attributes

This element only includes global attributes.

DOM Interface

This element implements the {{domxref("SVGGElement")}} interface.

Example

css
html,
body,
svg {
  height: 100%;
}
html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <!-- Using g to inherit presentation attributes -->
  <g fill="white" stroke="green" stroke-width="5">
    <circle cx="40" cy="40" r="25" />
    <circle cx="60" cy="60" r="25" />
  </g>
</svg>

{{EmbedLiveSample('Example', 100, '100%')}}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}