W3cubDocs

/SVG

<set>

The SVG <set> element provides a simple means of just setting the value of an attribute for a specified duration.

It supports all attribute types, including those that cannot reasonably be interpolated, such as string and boolean values. For attributes that can be reasonably be interpolated, the <animate> is usually preferred.

Note: The <set> element is non-additive. The additive and accumulate attributes are not allowed, and will be ignored if specified.

Example

<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
  <style>
    rect {
      cursor: pointer;
    }
    .round {
      rx: 5px;
      fill: green;
    }
  </style>

  <rect id="me" width="10" height="10">
    <set attributeName="class" to="round" begin="me.click" dur="2s" />
  </rect>
</svg>

Attributes

to

This attribute defines the value to be applied to the target attribute for the duration of the animation. The value must match the requirements of the target attribute. Value type: <anything>; Default value: none; Animatable: no

Animation Attributes

Global attributes

Usage notes

Categories Animation element
Permitted content Any number of the following elements, in any order:
Descriptive elements

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
set 2 ≤79 4 No ≤12.1 3 4.4 18 4 ≤12.1 1 1.0
to 2 ≤79 4 No ≤12.1 3 4.4 18 4 Yes 1 1.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Element/set