What is the difference between svg’s x and dx attribute?

x and y are absolute coordinates and dx and dy are relative coordinates (relative to the specified x and y).

In my experience, it is not common to use dx and dy on <text> elements (although it might be useful for coding convenience if you, for example, have some code for positioning text and then separate code for adjusting it).

dx and dy are mostly useful when using <tspan> elements nested inside a <text> element to establish fancier multi-line text layouts.

For more details you can check out the Text section of the SVG spec.

Leave a Comment