text-anchor Redirect 1

« SVG Attribute reference home

The text-anchor attribute is used to align (start-, middle- or end-alignment) a string of text relative to a given point.

The text-anchor attribute is applied to each individual text chunk within a given <text> element. Each text chunk has an initial current text position, which represents the point in the user coordinate system resulting from (depending on context) application of the x and y attributes on the <text> element, any x or y attribute values on a <tspan>, <tref> or <altglyph> element assigned explicitly to the first rendered character in a text chunk, or determination of the initial current text position for a <textpath> element.

As a presentation attribute, it also can be used as a property directly inside a CSS stylesheet.

Usage context

Categories Presentation attribute
Value start | middle | end | inherit
Animatable Yes
Normative document SVG 1.1 (2nd Edition)
start
The rendered characters are aligned such that the start of the text string is at the initial current text position. For Latin in its usual orientation this is equivalent to left alignment. For scripts that are inherently right to left such as Hebrew and Arabic, this is equivalent to right alignment. For Asian text with a vertical primary text direction, this is comparable to top alignment.
middle
The rendered characters are aligned such that the middle of the text string is at the current text position. (For text on a path, conceptually the text string is first laid out in a straight line. The midpoint between the start of the text string and the end of the text string is determined. Then, the text string is mapped onto the path with this midpoint placed at the current text position.)
end
The rendered characters are aligned such that the end of the text string is at the initial current text position.For Latin in its usual orientation this is equivalent to right alignment. For scripts that are inherently right to left such as Hebrew and Arabic, this is equivalent to left alignment.

Example

Source code Output result

Unable to find file text-anchor.svg

Unable to find file text-anchor.svg

» text-anchor.svg

Elements

The following elements can use the text-anchor attribute

Document Tags and Contributors

Contributors to this page: Sheppy
Last updated by: Sheppy,