大网数据广告活动
Web 标准与前端开发

path

· 52CE 我爱测

The **`path`** attribute has two different meanings, either it defines a text path along which the characters of a text are rendered, or a motion path along which a referenced element is animated.

The path attribute has two different meanings, either it defines a text path along which the characters of a text are rendered, or a motion path along which a referenced element is animated.

You can use this attribute with the following SVG elements:

  • animateMotion
  • textPath

animateMotion

For animateMotion, path defines the motion path, expressed in the same format and interpreted the same way as the d geometric property for the path element. The effect of a motion path animation is a translation along the x- and y-axes of the current user coordinate system by the x and y values computed over time.

<table class="properties"> <tbody> <tr> <th scope="row">Value</th> <td><code><path-data></code></td> </tr> <tr> <th scope="row">Default value</th> <td><em>None</em></td> </tr> <tr> <th scope="row">Animatable</th> <td>No</td> </tr> </tbody> </table>

  • <path-data>
    • : This value defines the motion path along which the referenced element is animated. For detailed information about the commands that can be used, see the explanation for the d attribute.

textPath

For textPath, path defines the path onto which the glyph of a text element will be rendered. An empty string indicates that there is no path data for the element. This means that the text within the <textPath> element does not render or contribute to the bounding box of the <text> element. If the attribute is not specified, the path specified in href is used instead.

<table class="properties"> <tbody> <tr> <th scope="row">Value</th> <td><code><path-data></code></td> </tr> <tr> <th scope="row">Default value</th> <td><em>Path specified in href</em></td> </tr> <tr> <th scope="row">Animatable</th> <td>Yes</td> </tr> </tbody> </table>

  • <path-data>
    • : This value defines the text path along which the glyphs of the <text> element are aligned. For detailed information about the commands that can be used, see the explanation for the d attribute.

Example

html,
body,
svg {
  height: 100%;
}
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <path
    id="MyPath"
    fill="none"
    stroke="silver"
    d="M10,90 Q90,90 90,45 Q90,10 50,10 Q10,10 10,40 Q10,70 45,70 Q70,70 75,50" />

  <text>
    <textPath
      path="M10,90 Q90,90 90,45 Q90,10 50,10 Q10,10 10,40 Q10,70 45,70 Q70,70 75,50">
      Quick brown fox jumps over the lazy dog.
    </textPath>
  </text>
</svg>

Example

Specifications

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。