This wiki has been archived and is now read-only.


From HTML Wiki
Jump to: navigation, search


The <g> element is a container element for grouping together related graphics elements.


  • A group of elements, as well as individual objects, can be given a name using the id attribute. Named groups are needed for several purposes such as animation and re-usable objects. [Example A]

  • Grouping constructs, when used in conjunction with the <desc> and <title> elements, provide information about document structure and semantics. See also The desc element and The title element.

SVG Attributes


Example A

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
<svg xmlns="http://www.w3.org/2000/svg"
     version="1.1" width="5cm" height="5cm">
  <g id="group1" fill="red">
    <rect x="1cm" y="1cm" width="1cm" height="1cm"/>
    <rect x="3cm" y="1cm" width="1cm" height="1cm"/>

SVG Reference

The SVG1.1 specification defines the <g> element in 5.2.2 The g element.