|
|
Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
|
Container for definitions of reusable graphics elements.
It is not rendered directly, but its child elements can be referenced by a <use> or within a fill or stroke.
The <defs> element is SVG's "library" section: a place to declare reusable building blocks that should not be drawn where they appear. Anything inside <defs> is parsed and kept in memory, but is only rendered when something else explicitly references it - paint servers via fill="url(#id)" or stroke="url(#id)", <use> elements via href="#id", filters via filter="url(#id)", and so on.
By convention, almost all reusable content lives inside <defs>: <linearGradient> and <radialGradient> paint servers, <pattern> tiles, <filter> effects, <clipPath> and <mask> regions, <marker> arrowheads, and <symbol> templates. Using <defs> keeps the drawable part of your document clean and signals intent to both tools and human readers.
The <defs> block itself is never rendered, but its children are referenced elsewhere via id. In the diagram below, the gradient is defined inside <defs> (left) and then referenced by the rectangle (right) via fill="url(#MyGradient)".