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

side

· 52CE 我爱测

The **`side`** attribute determines the side of a path the text is placed on (relative to the path direction).

The side attribute determines the side of a path the text is placed on (relative to the path direction).

You can use this attribute with the following SVG elements:

  • textPath

Example

Basic usage

The following example draws two circular text paths, displaying text on the left-hand side and the right-hand side, respectively.

HTML

html,
body,
svg {
  height: 100%;
}

text {
  font:
    25px "Helvetica",
    "Arial",
    sans-serif;
}
<svg viewBox="0 0 420 200" xmlns="http://www.w3.org/2000/svg">
  <text>
    <textPath href="#circle1" side="left">Text on left of path</textPath>
  </text>
  <text>
    <textPath href="#circle2" side="right">Text on right of path</textPath>
  </text>

  <circle id="circle1" cx="100" cy="100" r="70" fill="none" stroke="silver" />
  <circle id="circle2" cx="320" cy="100" r="70" fill="none" stroke="silver" />
</svg>

Result

Browsers that support setting the side attribute will display text to the left (outside) and to the right (inside) of the circular text path below.

Basic usage

Usage notes

<table class="properties"> <tbody> <tr> <th scope="row">Value</th> <td><code>left</code> | <code>right</code></td> </tr> <tr> <th scope="row">Default value</th> <td><code>left</code></td> </tr> <tr> <th scope="row">Animatable</th> <td>Yes</td> </tr> </tbody> </table>

  • left
    • : This value places the text on the left side of the path (relative to the path direction).
  • right
    • : This value places the text on the right side of the path (relative to the path direction). This effectively reverses the path direction.

Specifications

Browser compatibility

See also

  • SVGTextPathElement.side

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

资料来源与适用范围

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

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

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