Using an RGB or HEX color code in HTML you can change the color of the text, background, url, font, table or the whole page.

Colors in HTML

The value for the color property can be set in three main ways:

  • by color name, for example, red, green, blue
  • by hexadecimal number: from #000000 to #ffffff
  • by color code in the RGB palette: from rgb (0, 0, 0) to rgb(255, 255, 255)

The name of the color is relatively simple. The only limitation is that we have to choose a color from several predefined options.

The standard set of HTML colors consists of 140 different values. If you need a color that is not represented there, you will need to use a hexadecimal format (HEX code) or RGB.

HEX color codes in HTML

The HEX code always starts with a # followed by a 3-byte hexadecimal number (6 digits in total). Each byte is responsible for the intensity of one of the three primary colors: the first is responsible for the intensity of red, the second for green, and the third for blue:

The value 00 is the lowest intensity, FF is the highest. For example, to get white, you need to “mix” three primary colors with maximum intensity: #FFFFFF. To obtain black, the intensity of all colors should be minimal: #000000.

— So it’s the same as in the drawing class - to get any color you just need to mix red, blue, and green.

— Exactly. To get the red color, you need to set the maximum value for the byte responsible for the red color, and for the rest - the minimum: ##FF0000.

— Then for green, the HEX code will be: #00FF00

RGB palette of HTML colors

In the RGB palette, the color is mixed in a similar way by mixing the intensity of red, green, and blue colors. Hence the abbreviation RGB. Only the intensity is set here by numbers 0 from 255, where 0 is the lowest intensity, 255 is the highest. For example, green would look like this: rgb (0, 255, 0);

All of these values are suitable for other situations where color is needed, for example, in background-color.

A Table of 140 HTML colors with names and codes (string, HEX, rgb)

In this table you’ll find all colors that have an HTML name and a code. If you want to become a FULL STACK JS Developer, you can join my modern web development course

ColorNameHTML string codeHEX codeRGB code
 maroonmaroon#800000(128,0,0)
 dark reddarkred#8B0000(139,0,0)
 brownbrown#A52A2A(165,42,42)
 fire brickfirebrick#B22222(178,34,34)
 crimsoncrimson#DC143C(220,20,60)
 redred#FF0000(255,0,0)
 tomatotomato#FF6347(255,99,71)
 coralcoral#FF7F50(255,127,80)
 indian redindianred#CD5C5C(205,92,92)
 light corallightcoral#F08080(240,128,128)
 dark salmondarksalmon#E9967A(233,150,122)
 salmonsalmon#FA8072(250,128,114)
 light salmonlightsalmon#FFA07A(255,160,122)
 orange redorangered#FF4500(255,69,0)
 dark orangedarkorange#FF8C00(255,140,0)
 orangeorange#FFA500(255,165,0)
 goldgold#FFD700(255,215,0)
 dark golden roddarkgoldenrod#B8860B(184,134,11)
 golden rodgoldenrod#DAA520(218,165,32)
 pale golden rodpalegoldenrod#EEE8AA(238,232,170)
 dark khakidarkkhaki#BDB76B(189,183,107)
 khakikhaki#F0E68C(240,230,140)
 oliveolive#808000(128,128,0)
 yellowyellow#FFFF00(255,255,0)
 yellow greenyellowgreen#9ACD32(154,205,50)
 dark olive greendarkolivegreen#556B2F(85,107,47)
 olive drabolivedrab#6B8E23(107,142,35)
 lawn greenlawngreen#7CFC00(124,252,0)
 chartreusechartreuse#7FFF00(127,255,0)
 green yellowgreenyellow#ADFF2F(173,255,47)
 dark greendarkgreen#006400(0,100,0)
 greengreen#008000(0,128,0)
 forest greenforestgreen#228B22(34,139,34)
 limelime#00FF00(0,255,0)
 lime greenlimegreen#32CD32(50,205,50)
 light greenlightgreen#90EE90(144,238,144)
 pale greenpalegreen#98FB98(152,251,152)
 dark sea greendarkseagreen#8FBC8F(143,188,143)
 medium spring greenmediumspringgreen#00FA9A(0,250,154)
 spring greenspringgreen#00FF7F(0,255,127)
 sea greenseagreen#2E8B57(46,139,87)
 medium aquamarinemediumaquamarine#66CDAA(102,205,170)
 medium sea greenmediumseagreen#3CB371(60,179,113)
 light sea greenlightseagreen#20B2AA(32,178,170)
 dark slate graydarkslategray#2F4F4F(47,79,79)
 tealteal#008080(0,128,128)
 dark cyandarkcyan#008B8B(0,139,139)
 aquaaqua#00FFFF(0,255,255)
 cyancyan#00FFFF(0,255,255)
 light cyanlightcyan#E0FFFF(224,255,255)
 dark turquoisedarkturquoise#00CED1(0,206,209)
 turquoiseturquoise#40E0D0(64,224,208)
 medium turquoisemediumturquoise#48D1CC(72,209,204)
 pale turquoisepaleturquoise#AFEEEE(175,238,238)
 aquamarineaquamarine#7FFFD4(127,255,212)
 powder bluepowderblue#B0E0E6(176,224,230)
 cadet bluecadetblue#5F9EA0(95,158,160)
 steel bluesteelblue#4682B4(70,130,180)
 cornflower bluecornflowerblue#6495ED(100,149,237)
 deep sky bluedeepskyblue#00BFFF(0,191,255)
 dodger bluedodgerblue#1E90FF(30,144,255)
 light bluelightblue#ADD8E6(173,216,230)
 sky blueskyblue#87CEEB(135,206,235)
 light sky bluelightskyblue#87CEFA(135,206,250)
 midnight bluemidnightblue#191970(25,25,112)
 navynavy#000080(0,0,128)
 dark bluedarkblue#00008B(0,0,139)
 medium bluemediumblue#0000CD(0,0,205)
 blueblue#0000FF(0,0,255)
 royal blueroyalblue#4169E1(65,105,225)
 blue violetblueviolet#8A2BE2(138,43,226)
 indigoindigo#4B0082(75,0,130)
 dark slate bluedarkslateblue#483D8B(72,61,139)
 slate blueslateblue#6A5ACD(106,90,205)
 medium slate bluemediumslateblue#7B68EE(123,104,238)
 medium purplemediumpurple#9370DB(147,112,219)
 dark magentadarkmagenta#8B008B(139,0,139)
 dark violetdarkviolet#9400D3(148,0,211)
 dark orchiddarkorchid#9932CC(153,50,204)
 medium orchidmediumorchid#BA55D3(186,85,211)
 purplepurple#800080(128,0,128)
 thistlethistle#D8BFD8(216,191,216)
 plumplum#DDA0DD(221,160,221)
 violetviolet#EE82EE(238,130,238)
 fuchsiafuchsia#FF00FF(255,0,255)
 orchidorchid#DA70D6(218,112,214)
 medium violet redmediumvioletred#C71585(199,21,133)
 pale violet redpalevioletred#DB7093(219,112,147)
 deep pinkdeeppink#FF1493(255,20,147)
 hot pinkhotpink#FF69B4(255,105,180)
 light pinklightpink#FFB6C1(255,182,193)
 pinkpink#FFC0CB(255,192,203)
 antique whiteantiquewhite#FAEBD7(250,235,215)
 beigebeige#F5F5DC(245,245,220)
 bisquebisque#FFE4C4(255,228,196)
 blanched almondblanchedalmond#FFEBCD(255,235,205)
 wheatwheat#F5DEB3(245,222,179)
 corn silkcornsilk#FFF8DC(255,248,220)
 lemon chiffonlemonchiffon#FFFACD(255,250,205)
 light golden rod yellowlightgoldenrodyellow#FAFAD2(250,250,210)
 light yellowlightyellow#FFFFE0(255,255,224)
 saddle brownsaddlebrown#8B4513(139,69,19)
 siennasienna#A0522D(160,82,45)
 chocolatechocolate#D2691E(210,105,30)
 peruperu#CD853F(205,133,63)
 sandy brownsandybrown#F4A460(244,164,96)
 burly woodburlywood#DEB887(222,184,135)
 tantan#D2B48C(210,180,140)
 rosy brownrosybrown#BC8F8F(188,143,143)
 moccasinmoccasin#FFE4B5(255,228,181)
 navajo whitenavajowhite#FFDEAD(255,222,173)
 peach puffpeachpuff#FFDAB9(255,218,185)
 misty rosemistyrose#FFE4E1(255,228,225)
 lavender blushlavenderblush#FFF0F5(255,240,245)
 linenlinen#FAF0E6(250,240,230)
 old laceoldlace#FDF5E6(253,245,230)
 papaya whippapayawhip#FFEFD5(255,239,213)
 sea shellseashell#FFF5EE(255,245,238)
 mint creammintcream#F5FFFA(245,255,250)
 slate grayslategray#708090(112,128,144)
 light slate graylightslategray#778899(119,136,153)
 light steel bluelightsteelblue#B0C4DE(176,196,222)
 lavenderlavender#E6E6FA(230,230,250)
 floral whitefloralwhite#FFFAF0(255,250,240)
 alice bluealiceblue#F0F8FF(240,248,255)
 ghost whiteghostwhite#F8F8FF(248,248,255)
 honey dewhoneydew#F0FFF0(240,255,240)
 ivoryivory#FFFFF0(255,255,240)
 azureazure#F0FFFF(240,255,255)
 snowsnow#FFFAFA(255,250,250)
 blackblack#000000(0,0,0)
 dim graydimgray#696969(105,105,105)
 graygray#808080(128,128,128)
 dark gray / dark greydarkgray#A9A9A9(169,169,169)
 silversilver#C0C0C0(192,192,192)
 light gray / light greylightgray#D3D3D3(211,211,211)
 gainsborogainsboro#DCDCDC(220,220,220)
 white smokewhitesmoke#F5F5F5(245,245,245)
 whitewhite#FFFFFF(255,255,255)

Read more HTML tutorials or Learn Full-Stack JS from scratch!