このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

SVGTextPathElement: href プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

hrefSVGTextPathElement インターフェイスの読み取り専用プロパティで、この <textPath> 要素の href 属性(または非推奨の xlink:href 属性)を反映します。

SVGAnimatedString オブジェクトです。

href プロパティにアクセス

html
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">
  <defs>
    <path id="myPath" d="M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80" />
  </defs>
  <text font-size="20" fill="blue">
    <textPath id="myTextPath" href="#myPath">
      このテキストはパスに沿います。
    </textPath>
  </text>
</svg>
js
const textPath = document.getElementById("myTextPath");

// href プロパティにアクセス
console.log(textPath.href.baseVal); // 出力結果: "#myPath"

仕様書

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGURIReference__href

ブラウザーの互換性

関連情報

  • SVG の href 属性