mozilla

tspan

Within a <text> element, text and font properties and the current text position can be adjusted with absolute or relative coordinate values by including a tspan element.

<text>元素中,文本和字体属性以及当前文本的位置通过包含tspan元素的绝对或相对坐标可以调整。

Usage context

Categories

类别

Text content element, Text content child element

文本内容元素,文本内容子元素

Permitted content

允许内容

Character data and any number of the following elements, in any order:
Descriptive elements »
<a>, <altglyph>, <animate>, <animatecolor>, <set>, <tref>, <tspan>

字符数据和任何数量的以下元素,不限顺序:

 

Normative document SVG 1.1 (2nd Edition)

Example

Source code
<?xml version="1.0"?>
<svg width="250" height="40" viewBox="0 0 250 40"
     xmlns="http://www.w3.org/2000/svg" version="1.1">

	<style>
<![CDATA[
text{
    font: 20px Verdana, Helvetica, Arial, sans-serif;
}

tspan{
	fill: red;
	font-weight: bold
}
]]>
	</style>

    <text x="15" y="30">You are 
    	<tspan>not</tspan> 
    	a banana
    </text>
</svg>
Output result

» tspan.svg

Attributes

Global attributes

Specific attributes

DOM Interface

This element implements the SVGTSpanElement interface.

Browser compatibility

Feature Chrome Firefox (Gecko) IE Opera Safari
Basic support 1.0 1.5 (1.8) 9.0 9.0 3.0.4
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 3.0 1.0 (1.8) Not supported (Yes) 3.0.4

The chart is based on these sources.

Gecko-specific notes

Various presentation attributes don't work.

The attribute rotate was implemented in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1).

See also

文档标签和贡献者

向此页面作出贡献: teoli, flyonok
最后编辑者: teoli,