Encoding Colors in Strings
The following table lists the ways a color can be represented by a string.
Format | Example | Description |
---|---|---|
rgb(red, green, blue) | rgb(255,0,0) for pure red. | See below. |
rgba(red, green, blue, alpha) | rgba(255, 0, 255, 100) for semi-transparent magenta. | See below. |
An SVG color name | red | |
HTML color | #FF0000 for pure red. | See HTML Color Codes |
In the RGB and RGBA syntax, the components red, green, blue and alpha shall be numbers in the [0, 255] range. The alpha gives the opacity: a value of 0 means completely transparent and 255 means completely opaque.