Styles in standalone SVG images

While all the examples so far have been about inline SVG inside an HTML document, you can also use CSS within a standalone SVG image. The following SVG image shows using CSS to adjust the display of multiple SVG text elements. Interesting details include the character data (<![CDATA[ ]]>) block wrapping the styles contained in the style element:

If you haven't dealt with a lot of XML (and it's not nearly as common as it once was, so that might be the case), CDATA is used to indicate to the XML parser that the section might contain characters that could be interpreted as XML, but shouldn't be.  JavaScript (with ...

Get Mastering SVG 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.