Positioning characters in SVG

Character-by-character positioning for SVG text can be assigned by passing a list of values to the x , y , dx , dy , and rotate attributes on a <text> or <tspan> element, without having to divide the text into single-character spans.

For assigning the values to characters, the sequence continues within nested <tspan> elements. However, if a value is assigned for a character in a nested element's attribute it over-rides the value from the parent.

Note that dy and dx assign a change in position relative to where the character would normally follow the previous one, while x , y and rotate assign absolute values for each character.

For rotate , if there are fewer values than characters, the last value is repeated for the rest of that element. The result is that all the characters in "very" have a rotation of -60 degrees despite only one value being specified, and the last few characters of "text" all lean in the same direction after the text element's list of rotation values is used up.

This differs from the positioning attributes. These normally pass on their values implicitly to the next character (by their effect on the cursor position), so there is no need to repeat a value until the end of the string. Importantly, if you don't specify a value for every character in an element, but do have a value for that character in the parent element, the parent's value will be used. The "l" and "y" in "wobbly" inherit the sinking effects of the parent's dy attribute after the four values for dy in that span are used up.

Finally, note that the dy values are added on after the y value is calculated (and same with dx and x ), so the characters assigned a 'y' value of 100 are positioned 10 pixels below that line.

Want more? Read the specs

P.S. This example also makes use of the letter-spacing and word-spacing CSS properties to spread out the text. Unfortunately, Firefox doesn't seem to have implemented those yet!