<tspan>

SVG の <tspan> 要素は、 <text> 要素内にあるサブテキストやその他の <tspan> 要素を定義します。これにより、必要に応じてサブテキストのスタイルや位置を調整することができます。

html
<svg viewBox="0 0 240 40" xmlns="http://www.w3.org/2000/svg">
  <style>
    text {
      font: italic 12px serif;
    }
    tspan {
      font: bold 10px sans-serif;
      fill: red;
    }
  </style>

  <text x="10" y="30" class="small">
    You are
    <tspan>not</tspan>
    a banana!
  </text>
</svg>

属性

x

テキストのベースラインの開始点の X 座標です。 値の型: <length>|<percentage> ; 既定値: none; Animatable: yes

y

テキストのベースラインの開始点の Y 座標です。 値の型: <length>|<percentage> ; 既定値: none; Animatable: yes

dx

テキストの位置を直前のテキスト要素から水平方向にずらします。 値の型: <length>|<percentage> ; Default value: none; Animatable: yes

dy

テキストの位置を直前のテキスト要素から垂直方向にずらします。 値の型: <length>|<percentage> ; 既定値: none; Animatable: yes

rotate (en-US)

それぞれの文字の向きを回転します。文字ごとに個別に回転させることができます。 値の型: <list-of-number> ; 既定値: none; Animatable: yes

lengthAdjust

テキストをtextLength 属性で定義された幅に合わせるために伸縮する方法です。 値の型: spacing|spacingAndGlyphs; 既定値: spacing; Animatable: yes

textLength (en-US)

テキストを伸縮して合わせる幅です。 値の型: <length>|<percentage> ; 既定値: none; Animatable: yes

グローバル属性

コア属性

特に: id, tabindex (en-US)

スタイル属性
class (en-US), style (en-US)
条件処理属性

特に: requiredExtensions, systemLanguage (en-US)

Event Attributes

グローバルイベント属性, グラフィックイベント属性

プレゼンテーション属性

特に: clip-path (en-US), clip-rule (en-US), color, color-interpolation, color-rendering, cursor (en-US), display (en-US), dominant-baseline (en-US), fill, fill-opacity, fill-rule, filter (en-US), mask, opacity (en-US), pointer-events (en-US), shape-rendering (en-US), stroke, stroke-dasharray, stroke-dashoffset, stroke-linecap, stroke-linejoin, stroke-miterlimit, stroke-opacity (en-US), stroke-width, text-anchor (en-US), transform, vector-effect, visibility (en-US)

Aria 属性

aria-activedescendant, aria-atomic, aria-autocomplete, aria-busy, aria-checked, aria-colcount, aria-colindex, aria-colspan, aria-controls, aria-current, aria-describedby, aria-details, aria-disabled, aria-dropeffect, aria-errormessage, aria-expanded, aria-flowto, aria-grabbed, aria-haspopup, aria-hidden, aria-invalid, aria-keyshortcuts, aria-label, aria-labelledby, aria-level, aria-live, aria-modal, aria-multiline, aria-multiselectable, aria-orientation, aria-owns, aria-placeholder, aria-posinset, aria-pressed, aria-readonly, aria-relevant, aria-required, aria-roledescription, aria-rowcount, aria-rowindex, aria-rowspan, aria-selected, aria-setsize, aria-sort, aria-valuemax, aria-valuemin, aria-valuenow, aria-valuetext, role

使用場面

カテゴリーテキストコンテンツ要素、テキストコンテンツの子要素
許可されている内容任意の順で文字データと任意の数の以下の要素。
説明的要素
<a><animate><set><tref> (en-US)<tspan>

仕様書

Specification
Scalable Vector Graphics (SVG) 2
# TextElement

ブラウザーの互換性

BCD tables only load in the browser