Colours E-mail

Colour notation

The context API calls that have a colour as a parameter accept colours as a string in two different forms, one of which specifies the red, green, blue and alpha components, and other just the red, green and blue, assgned the resulting colour an alpha value of 1.0.

#rrggbb

  • Creates a colour with an alpha component of 1.0, making it completely opaque.
  • rr, gg and bb are the red, green and blue components respectively, specified as a two digit hexadecimal values.
  • Invalid values will return the default value of black.

rgba (red, green, blue, alpha)

  • Creates a colour with a specified alpha component.
  • red, green and blue must be in the range of 0 to 255.
  • alpha is the alpha component for the colour, expressed as a value in the range of 0.0 (transparent) to 1.0 (opaque).
  • Invalid values will return the default value of black.

Unfortunately, your browser does not support modern web standards.
Please use one of the supported browsers listed below, they're free to download and use.

Supported browsers: Firefox, Safari, Chrome, Opera, and Konqueror.


Source (click to expand)

var cnv = document.getElementById('canvas');
var ctx = cnv.getContext('2d');
ctx.width = ctx.width; // Clear the context

// A blue and red rectangle demonstrating the #rrggbb format.
ctx.fillStyle = "#FF0000";
ctx.fillRect(20, 20, 80, 60);
ctx.fillStyle = "#0000FF";
ctx.fillRect(40, 40, 80, 60);

// A blue rectangle demonstrating the rgba format, where the
// a component is used to set transparancy, in this case, 
// setting the blue rectangle to 50% transparent.
ctx.fillStyle = "rgba(255, 0, 0, 1)";
ctx.fillRect(180, 20, 80, 60);
ctx.fillStyle = "rgba(0, 0, 255, 0.5)";
ctx.fillRect(200, 40, 80, 60);

Standard CSS colours

Below is table listing the standard CSS colours, including the unofficial name which should not be used when specifying a colour.

NameHex CodeColourNameHex CodeColour
Alice Blue#F0F8FFLight Salmon#FFA07A
Antique White#FAEBD7Light Sea Green#20B2AA
Aqua#00FFFFLight Sky Blue#87CEFA
Aquamarine#7FFFD4Light Slate Gray#778899
Azure#F0FFFFLight Steel Blue#B0C4DE
Beige#F5F5DCLight Yellow#FFFFE0
Bisque#FFE4C4Lime#00FF00
Black#000000Lime Green#32CD32
Blanched Almond#FFEBCDLinen#FAF0E6
Blue#0000FFMagenta#FF00FF
Blue Violet#8A2BE2Maroon#800000
Brown#A52A2AMedium Aqua Marine#66CDAA
Burly Wood#DEB887Medium Blue#0000CD
Cadet Blue#5F9EA0Medium Orchid#BA55D3
Chartreuse#7FFF00Medium Purple#9370D8
Chocolate#D2691EMedium Sea Green#3CB371
Coral#FF7F50Medium Slate Blue#7B68EE
Cornflower Blue#6495EDMedium Spring Green#00FA9A
Cornsilk#FFF8DCMedium Turquoise#48D1CC
Crimson#DC143CMedium Violet Red#C71585
Cyan#00FFFFMidnight Blue#191970
Dark Blue#00008BMint Cream#F5FFFA
Dark Cyan#008B8BMisty Rose#FFE4E1
Dark Golden Rod#B8860BMoccasin#FFE4B5
Dark Gray#A9A9A9Navajo White#FFDEAD
Dark Green#006400Navy#000080
Dark Khaki#BDB76BOld Lace#FDF5E6
Dark Magenta#8B008BOlive#808000
Dark Olive Green#556B2FOlive Drab#6B8E23
Dark Orange#FF8C00Orange#FFA500
Dark Orchid#9932CCOrange Red#FF4500
Dark Red#8B0000Orchid#DA70D6
Dark Salmon#E9967APale Golden Rod#EEE8AA
Dark Sea Green#8FBC8FPale Green#98FB98
Dark Slate Blue#483D8BPale Turquoise#AFEEEE
Dark Slate Gray#2F4F4FPale Violet Red#D87093
Dark Turquoise#00CED1Papaya Whip#FFEFD5
Dark Violet#9400D3Peach Puff#FFDAB9
Deep Pink#FF1493Peru#CD853F
Deep Sky Blue#00BFFFPink#FFC0CB
Dim Gray#696969Plum#DDA0DD
Dodger Blue#1E90FFPowder Blue#B0E0E6
Fire Brick#B22222Purple#800080
Floral White#FFFAF0Red#FF0000
Forest Green#228B22Rosy Brown#BC8F8F
Fuchsia#FF00FFRoyal Blue#4169E1
Gainsboro#DCDCDCSaddle Brown#8B4513
Ghost White#F8F8FFSalmon#FA8072
Gold#FFD700Sandy Brown#F4A460
Golden Rod#DAA520Sea Green#2E8B57
Gray#808080Sea Shell#FFF5EE
Green#008000Sienna#A0522D
Green Yellow#ADFF2FSilver#C0C0C0
Honey Dew#F0FFF0Sky Blue#87CEEB
HotPink#FF69B4Slate Blue#6A5ACD
Indian Red #CD5C5CSlate Gray#708090
Indigo #4B0082Snow#FFFAFA
Ivory#FFFFF0Spring Green#00FF7F
Khaki#F0E68CSteel Blue#4682B4
Lavender#E6E6FATan#D2B48C
Lavender Blush#FFF0F5Teal#008080
Lawn Green#7CFC00Thistle#D8BFD8
Lemon Chiffon#FFFACDTomato#FF6347
Light Blue#ADD8E6Turquoise#40E0D0
Light Coral#F08080Violet#EE82EE
Light Cyan#E0FFFFWheat#F5DEB3
Light Golden Rod Yellow#FAFAD2White#FFFFFF
Light Green#90EE90White Smoke#F5F5F5
Light Grey#D3D3D3Yellow#FFFF00
LightPink#FFB6C1Yellow Green#9ACD32