HTML Green Code

This page contains HTML code for coloring an element green. You can have green text, a green background, or a green border around an element.

Green Text

This example uses inline styles to set the text color to green (i.e. I use the style attribute against the HTML element).

In this case, I apply the styles against a <div> tag, but I could just have easily applied them against a <div> tag (for all text within that element) or even a <body> tag (for all text on the page).

Source CodeResult

Green text

Here's the same thing, but this time using embedded styles.

Source CodeResult

Green text

You could also place the CSS code into a external style sheet.

Green Background Color

You can set the background color of an element to green by using the CSS background-color property or the background shorthand property.

In this example, I've placed text inside a <div> tag, set its background color to green, and set its text color to orange.

Source CodeResult
Orange text, green background.

Green Border Color

In this example, I've added a green border around a <div> element.

Source CodeResult
I have a green border.

Green Color Codes

The above examples use green as the color value. I could just as easily used the hexadecimal or RGB color values and the result would've been the same.

Here are the various methods of specifying the color green in HTML.

Source CodeResult

Green text

Green text (hexadecimal #008000)

Green text (RGB value rgb(0,128,0))

Actually, the above examples don't use true green as in RGB ("Red Green Blue"). To do that, you need to use one of the following color codes:

Source CodeResult

Green text (hexadecimal #00ff00)

Green text (hexadecimal shorthand #0f0)

Green text (RGB value rgb(0,255,0))

Shades of Green

Here are some different shades of green that can be used instead of just plain old "green".

Color Name Hex Code RGB Decimal Code RGB
GreenYellow ADFF2F 173,255,47
Chartreuse 7FFF00 127,255,0
LawnGreen 7CFC00 124,252,0
Lime 00FF00 0,255,0
LimeGreen 32CD32 50,205,50
PaleGreen 98FB98 152,251,152
LightGreen 90EE90 144,238,144
MediumSpringGreen 00FA9A 0,250,154
SpringGreen 00FF7F 0,255,127
MediumSeaGreen 3CB371 60,179,113
SeaGreen 2E8B57 46,139,87
ForestGreen 228B22 34,139,34
Green 008000 0,128,0
DarkGreen 006400 0,100,0
YellowGreen 9ACD32 154,205,50
OliveDrab 6B8E23 107,142,35
Olive 808000 128,128,0
DarkOliveGreen 556B2F 85,107,47
MediumAquamarine 66CDAA 102,205,170
DarkSeaGreen 8FBC8F 143,188,143
LightSeaGreen 20B2AA 32,178,170
DarkCyan 008B8B 0,139,139
Teal 008080 0,128,128