The style
attribute specifies style information for its element. It functions identically to the style
attribute in HTML.
Categories | Presentation attribute |
---|---|
Value | <style> |
Animatable | No |
Normative document | SVG 1.1 (2nd Edition) |
Note: In theory, the contentStyleType attribute could be used to specify styling languages other than CSS, like XSL(T). However, this was never implemented satisfactorily in browsers, so do not rely on it.
The following example shows styling of a rectangle with the style attribute using CSS as style sheet language.
<svg viewbox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg"> <rect height="300" width="600" x="200" y="100" style="fill: red; stroke: blue; stroke-width: 3"/> </svg>
The following elements can use the style
attribute
<clipPath>
<filter>
<font>
<foreignObject>
<glyphRef>
<stop>
<glyph>
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | Yes | Yes | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | Yes | Yes | Yes | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/style