---
title: addClassesToSVGElement
svgo:
  pluginId: addClassesToSVGElement
  parameters:
    classNames:
      description: Adds the specified class names to the outer most `<svg>` element.
      default: null
    className:
      description: Adds the specified class name to the outer most `<svg>` element. If `classNames` is specified, this is ignored.
---

Overrides the `class` attribute in the outer most `<svg>` element, omitting duplicates or null classes if found in your configuration.

:::caution

If there is no `class` attribute to begin with, it will be added. However, if the there were already classes assigned, these are removed and replaced with the classes configured in this plugin.

:::

If you have a standalone SVG, this is not an optimization and will increase the size of the SVG document. This plugin is only relevant when considering multiple SVGs that may be inlined a parent document.

By adding classes, if the parent document is aware, you can share styles across all inlined SVG elements.
