---
title: convertStyleToAttrs
svgo:
  pluginId: convertStyleToAttrs
  parameters:
    keepImportant:
      description: If to always keep [`!important`](https://developer.mozilla.org/docs/Web/CSS/important) styles.
      type: boolean
      default: false
---

Converts [presentation attributes](https://developer.mozilla.org/docs/Web/SVG/Attribute/Presentation) 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"/>
```
