CSS COLORS


HTML Colors can be specified using the pre-defined color names, or using RGB, RGBA or HEX values.

Let's see how we can specify the colors using color names.


Color Name


Let's have a look at few colors:


Orange

OrangeRed

DodgerBlue

Gold

DarkKhaki

MediumPurple

DarkViolet

SlateBlue

Chartreuse

HotPink

Yellow

LightCoral



CSS Text Colors


Text color can be changed using the CSS color property. Here's an example:


<p style="color:red">This statement is Red</p>
<p style="color:green">Why Green?</p>

Live Demo!


Output:

This statement is Red

Why Green?



CSS Border Colors


Bordor colors can be defined using the CSS border-color property or the shorthand approach. Here's an example:


<h2 style="border:2px solid red">Border will be Red</h2>
<h2 style="border:2px solid pink">We will get a pink border now</h2>
<h2 style="border:2px solid purple">We will get a purple border now</h2>

Live Demo!


Output:

Border will be Red

We will get a pink border now

We will get a purple border now



Color Values (RGB, RGBA, HSL, HEX, HSLA)


RGB, RGBA, HEX, HSL values can also be used to specify colors. Let's see how we can do that:

Color Name

Magenta


Orange

HEX Code

#FF00FF


#FFA500

RGB Code

rgb(255, 0, 255)


rgb(255, 165, 0)



Let's check an example on how we can use these colors:


<p style="color:darkred; background-color:pink;">Defining Color using Color Name</p>
<p style="color:#CD5C5C; background-color:#FFA07A;">Defining Color using Hex Color Code</p>
<p style="color:rgb(29, 131, 72); background-color:rgb(130, 224, 170 );">Defining Color using RGB Color Code</p>
<p style="background-color:rgba(255, 215, 0, 0.5);">Defining Color using RGBA Color Code</p>

Live Demo!


Output:

Defining Color using Color Name

Defining Color using Hex Color Code

Defining Color using RGB Color Code

Defining Color using RGBA Color Code


Here's the list of some more colors:


Color Name

HEX Code

RGB Code


IndianRed
#CD5C5C
rgb(205, 92, 92)
LightCoral
#F08080
rgb(240, 128, 128)

Salmon

#FA8072

rgb(250, 128, 114)

Crimson

#DC143C

rgb(220, 20, 60)

Red

#FF0000

rgb(255, 0, 0)

Pink

#FFC0CB

rgb(255, 192, 203)

HotPink

#FF69B4

rgb(255, 105, 180)

PaleVioletRed

#DB7093

rgb(219, 112, 147)

Coral

#FF7F50

rgb(255, 127, 80)

Tomato

#FF6347

rgb(255, 99, 71)

DarkOrange

#FF8C00

rgb(255, 140, 0)

Orange

#FFA500

rgb(255, 165, 0)

Gold

#FFD700

rgb(255, 215, 0)

Yellow

#FFFF00

rgb(255, 255, 0)

Khaki

#F0E68C

rgb(240, 230, 140)

Thistle

#D8BFD8

rgb(216, 191, 216)

Plum

#DDA0DD

rgb(221, 160, 221)

Violet

#EE82EE

rgb(238, 130, 238)

Magenta

#FF00FF

rgb(255, 0, 255)

Purple

#800080

rgb(128, 0, 128)