A gradient is a smooth transition from one color to another. In addition, several color transitions can be applied to the same element.
There are two main types of gradients in SVG:
The <linearGradient> element is used to define a linear gradient.
The <linearGradient> element must be nested within a <defs> tag. The <defs> tag is short for definitions and contains definition of special elements (such as gradients).
Linear gradients can be defined as horizontal, vertical or angular gradients:
Define an ellipse with a horizontal linear gradient from yellow to red:
Here is the SVG code:
For Opera users: View the SVG file (right-click on the SVG graphic to view the source).
Code explanation:
Define an ellipse with a vertical linear gradient from yellow to red:
Here is the SVG code:
For Opera users: View the SVG file (right-click on the SVG graphic to view the source).
Define an ellipse with a horizontal linear gradient from yellow to red, and add a text inside the ellipse:
Here is the SVG code:
For Opera users: View the SVG file (right-click on the SVG graphic to view the source).
Code explanation:
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $7.95/mo SEO Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| XML Editor - Free Trial! |
| FREE Website BUILDER |
| Free Website Templates Free CSS Templates |
| Make Your Own Website |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|