docs.rodeo

MDN Web Docs mirror

{{SVGRef}} 

The <set> SVG element provides a method of 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 {{SVGElement('animate')}}  is usually preferred.

[!NOTE] The <set> element is non-additive. The {{SVGAttr('additive')}}  and {{SVGAttr('accumulate')}}  attributes are not allowed, and will be ignored if specified.

Example

html,
body,
svg {
  height: 100%;
}
<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>

{{EmbedLiveSample('Example', 150, '100%')}} 

Attributes

Usage context

{{svginfo}} 

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN