W3cubDocs

/SVG

<linearGradient>

The <linearGradient> SVG element lets authors define linear gradients to fill or stroke graphical elements.

Usage context

Categories Gradient element
Permitted content Any number of the following elements, in any order:
Descriptive elements
<animate>, <animateTransform>, <set>, <stop>

Attributes

Global attributes

Specific attributes

DOM Interface

This element implements the SVGLinearGradientElement interface.

Example

<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

Specifications

Browser compatibilityUpdate compatibility data on GitHub

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 ? ? ? ? ? ? ?

See also

© 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