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 ForkJoinPool

P2P Networks Introduction


Java Persistence
Close TOC
All Tutorial Trails
All Trails
Table of contents (TOC) for this tutorial trail
Trail TOC
Table of contents (TOC) for this tutorial
Page TOC
Previous tutorial in this tutorial trail
Next tutorial in this tutorial trail