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

SVGElements/defs

From HTML Wiki
Jump to: navigation, search

<defs>

The <defs> element is a container element for referenced elements.

Point

  • Elements that are descendants of a 'defs' are not rendered directly. However, that the descendants of a 'defs' are always present in the source tree and thus can always be referenced by other elements. [Example A]


SVG Attributes

Examples

Example A

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
       "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="8cm" height="3cm"
      xmlns="http://www.w3.org/2000/svg" version="1.1">
  <defs>
    <linearGradient id="Gradient01">
      <stop offset="20%" stop-color="#39F" />
      <stop offset="90%" stop-color="#F3F" />
    </linearGradient>
  </defs>
  <rect x="1cm" y="1cm" width="6cm" height="1cm" 
        fill="url(#Gradient01)"  />
</svg>


SVG Reference

The SVG1.1 specification defines the <defs> element in 5.3.2 The defs element.