Adjusting Margins and Leading with the dx and dy Attributes

Now that you're able to add text, and consistent blocks of text, you can investigate adding margins to your text. In certain cases, you may find that offsetting your text from an edge or indenting certain lines of text becomes necessary. To accomplish this, there are two optional attributes that can be added to the tspan element: dx and dy. Both of these attributes determine the offset of the leftmost edge of the baseline; dx moves the edge horizontally, and dy moves the baseline vertically. Each accepts only numerical values to determine the amount of offset.

One example of the use of these attributes is indenting the first line of a text block, similar to a newspaper or book's handling ...

Get Sams Teach Yourself SVG in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.