Back to Svgo

convertStyleToAttrs

docs/04-plugins/convertStyleToAttrs.mdx

4.0.1833 B
Original Source

Converts presentation attributes in element styles to the equivalent XML attribute.

Presentation attributes can be used in both attributes and styles, but in most cases it'll take fewer bytes to use attributes. Consider the following:

xml
<rect width="100" height="100" style="fill:red"/>
<!-- vs -->
<rect width="100" height="100" fill="red"/>

However, because the style attribute doesn't require quotes between values, given enough presentation attributes, it can increase the size of the document:

xml
<rect width="100" height="100" style="fill:red;opacity:.5;stroke-dasharray:1;stroke:blue;stroke-opacity:.5"/>
<!-- vs -->
<rect width="100" height="100" fill="red" opacity=".5" stroke-dasharray="1" stroke="blue" stroke-opacity=".5"/>