--- title: tref slug: Web/SVG/Element/tref tags: - SVG - SVG文本内容 - 元素 - 参考 - 需要兼容性表 translation_of: Web/SVG/Element/tref ---
{{ SVGElement("text") }} 的文本内容既可以是直接嵌入在{{SVGElement("text")}}元素中的的字符数据 ,也可以是引用元素的字符数据内容,tref元素用来指定的包含文本内容的引用元素。
{{svginfo}}
<svg width="100%" height="100%" viewBox="0 0 1000 300"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<text id="ReferencedText">
Referenced character data
</text>
</defs>
<text x="100" y="100" font-size="45" >
Inline character data
</text>
<text x="100" y="200" font-size="45" fill="red" >
<tref xlink:href="#ReferencedText"/>
</text>
<!-- Show outline of canvas using 'rect' element -->
<rect x="1" y="1" width="998" height="298"
fill="none" stroke-width="2" />
</svg>
该元素实现了SVGTRefElement接口。