Draw a rectangle with a red and green gradient filling:
JavaScript:
The addColorStop method specifies a color, and where to position the color in a gradient object.
The addColorStop method is used togheter with the createLinearGradient method or the createRadialrGradient.
| JavaScript syntax: | gradient.addColorStop(0.5,"#FF0000"); |
|---|
![]()
The addColorStop method is supported in all major browsers.
| Parameter | Values | Description | Play it |
|---|---|---|---|
| position | number | A value between 0.0 and 1.0 where 0.0 is at the beginning of the gradient and 1.0 is at the end | Play it » |
| color | color | A CSS colorvalue representing a colorstop at the given position | Play it » |
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $3.98 Unlimited Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| XML Editor - Free Trial! |
| FREE Website BUILDER |
| Best Website Templates Top CSS Templates |
| CREATE HTML Websites |
| EASY WEBSITE BUILDER |
| 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 |
|---|