The <linearGradient> SVG element lets authors define linear gradients to fill or stroke graphical elements.
| Categories | Gradient element |
|---|---|
| Permitted content | Any number of the following elements, in any order: Descriptive elements <animate>, <animateTransform>, <set>, <stop>
|
This element implements the SVGLinearGradientElement interface.
<svg width="120" height="120" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="MyGradient">
<stop offset="5%" stop-color="green"/>
<stop offset="95%" stop-color="gold"/>
</linearGradient>
</defs>
<rect fill="url(#MyGradient)"
x="10" y="10" width="100" height="100"/>
</svg> | Screenshot | Live sample |
|---|---|
| Specification | Status | Comment |
|---|---|---|
| Scalable Vector Graphics (SVG) 2 The definition of '<linearGradient>' in that specification. | Candidate Recommendation | |
| Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of '<linearGradient>' in that specification. | Recommendation | Initial definition |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | 1 | Yes | 1.5 | 9 | 9 | 3.1 |
gradientTransform |
? | ? | ? | ? | ? | ? |
gradientUnits |
? | ? | ? | ? | ? | ? |
spreadMethod |
? | ? | ? | ? | ? | ? |
x1 |
? | ? | ? | ? | ? | ? |
x2 |
? | ? | ? | ? | ? | ? |
xlink:href
|
? | ? | ? | ? | ? | ? |
y1 |
? | ? | ? | ? | ? | ? |
y2 |
? | ? | ? | ? | ? | ? |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | 3 | 18 | Yes | 4 | Yes | 3.1 | ? |
gradientTransform |
? | ? | ? | ? | ? | ? | ? |
gradientUnits |
? | ? | ? | ? | ? | ? | ? |
spreadMethod |
? | ? | ? | ? | ? | ? | ? |
x1 |
? | ? | ? | ? | ? | ? | ? |
x2 |
? | ? | ? | ? | ? | ? | ? |
xlink:href
|
? | ? | ? | ? | ? | ? | ? |
y1 |
? | ? | ? | ? | ? | ? | ? |
y2 |
? | ? | ? | ? | ? | ? | ? |
© 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/Element/linearGradient