SVG tref element

Jakob Jenkov
Last update: 2014-06-15

The SVG <tref> element is used to reference texts that are defined by the <defs> element. This way you can display the same text multiple times in your SVG image, without having to include the text more than once.

Here is an example:

<svg xmlns=""

        <text id="theText">A text that is referenced.</text>

    <text x="20" y="10">
        <tref xlink:href="#theText" />
    <text x="30" y="30">
        <tref xlink:href="#theText" />

And here is the resulting image:

A text that is referenced.

Notice how the <text> element (inside the <defs> element) has an id attribute. This id attribute value is referenced from the xlink:href attribute of the <tref> element.

Jakob Jenkov

Featured Videos


Java Persistence
Close TOC

All Trails

Trail TOC

Page TOC