linearGradient element | SVGLinearGradientElement object
Defines a linear gradient that provides a smooth transition from one color to another. The gradient can be used to fill or stroke an object.
![]() ![]() |
DOM Information
Inheritance Hierarchy
Members
The SVGLinearGradientElement object has these types of members:
Properties
The SVGLinearGradientElement object has these properties.
| Property | Description |
|---|---|
|
Gets the names of the classes that are assigned to this object. | |
|
Gets a value that indicates whether referenced resources that are not in the current document are required to correctly render a given element. | |
|
Determines if an element can acquire keyboard focus (that is, receive keyboard events) and be a target for field-to-field navigation actions (such as when a user presses the Tab key). | |
|
Gets a value that contains the definition of an optional, additional transformation from the gradient coordinate system onto the target coordinate system. | |
|
Gets a value that indicates the type of coordinate system that is used because of a transformation. | |
|
Gets an | |
|
Gets the nearest ancestor svg element. | |
|
Gets a value that determines what happens if a gradient starts or ends inside the bounds of a target rectangle. | |
|
Gets a style object. | |
|
Gets the element that established the current viewport. | |
|
Gets or sets the x-coordinate for the begining of a gradient vector. | |
|
Gets or sets the x-coordinate for the end of a gradient vector. | |
|
Gets or sets the | |
|
Gets or sets the y-coordinate for the begining of a gradient vector. | |
|
Gets or sets the y-coordinate for the end of a gradient vector. |
Standards information
- Scalable Vector Graphics: Gradients and Patterns, Section 13.4.2
Remarks
Examples
In the following code example, a linear gradient fills a rectangle. The gradient is defined in a definition and fills the rectangle by referencing the gradient. The gradient runs from magenta to cyan. Copy this sample to a text file and save it with the .html file extension. Run it in Internet Explorer 9 to see the magenta-to-cyan gradient-filled rectangle.
The gradient-filled rectangle will look like this:
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<!-- Inline SVG -->
<svg width="400" height="400">
<defs>
<!-- Define linear gradient for magenta to cyan. -->
<linearGradient id="magenta2cyan" >
<!-- First color is magenta. -->
<stop offset="0%" style="stop-color:magenta"/>
<!-- Second color is cyan. -->
<stop offset="100%" style="stop-color:cyan"/>
</linearGradient>
</defs>
<!-- Rectangle fill is defined by linear gradient in defs. -->
<rect width="100" height="50" x="50" y="50"
style="fill:url(#magenta2cyan)"/>
</svg>
</body>
</html>
See also

