Export to GitHub

doctype-mirror - SVGSVGElement.wiki


You are here: Home > SVG Elements > svg element

Introduction

The <svg> element represents the root node of an SVG document or image. When included in an XML context (inline with XHTML or as a standalone SVG document), the <svg> element must include the SVG namespace (see Usage below).

Details

Usage

<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 300 200"> <!-- rest of SVG document goes here --> </svg>

Attributes

Common attributes:

  • width - if unspecified this value is 100%
  • height - if unspecified this value is 100%
  • viewBox - represents the coordinate system of the SVG document

DOM API

The <svg> element supports the DOM SVGSVGElement interface. Some of the noted methods of SVGSVGElement are:

  • NodeList getIntersectionList( SVGRect rect ):
    • returns the list of nodes whose bounding boxes intersect with the input rectangle
    • supported by Opera 9+
    • NOT yet supported by Mozilla, see this bug
    • NOT yet supported by Webkit, see this bug
  • NodeList getEnclosureList( SVGRect rect ):
    • returns the list of nodes whose bounding boxes are completely enclosed by the input rectangle
    • supported by Opera 9+
    • NOT yet supported by Mozilla, see this bug
    • NOT yet supported by Webkit, see this bug

Reference