CSS Colors

CSS provides different options to define colors for HTML Page.

  • CSS Color can be applied to text or fonts in HTML Tags
  • CSS Color can be applied to background areas of HTML Tags & page.
  • CSS Color can be applied to borders of various HTML Elements

CSS Colors value can be specified in various formats:

Format Name Color Value CSS Example
Color Name red p { color: red }
Hexadecimal (Hex) #RRGGBB p { color: #00FF00; }
Short Hex Code #RGB p { color : #F00; }
RGB % rgb(rrr%,ggg%,bbb%) p { color : rgb(255, 0, 0); }
RGB Absolute rgb(rrr,ggg,bbb) p { color : rgb(255,0,0); }

Some Color Codes

All modern browsers supports hundred of colors. You can combine different color values & create various color shades.

There are many online tools & websites available that provides list of colors as well. For Example: www.w3schools.com has long list of color codes and www.quackit.com also provides tool to generate color codes by simply picking any color.

Following table provide list of some common colors with code values that you can use for practice.

Color Output RGB Value Hex Code Short Hex Color Name
  rgb(0,0,0) #000000 #000 black
  rgb(255,255,255) #FFFFFF #FFF white
  rgb(255,0,0) #FF0000 #F00 red
  rgb(0,255,0) #00FF00 #0F0 lime
  rgb(0,0,255) #0000FF #00F blue
  rgb(255,255,0) #FFFF00 #FF0 yellow
  rgb(0,255,255) #00FFFF #0FF cyan
  rgb(255,0,255) #FF00FF #F0F magenta

Example of HTML Program using CSS Colors

We will create a HTML Program that will use different colors on different tags. Following example will use different CSS Color Values to apply colors.

We will read CSS background-color & color properties detail in later chapters.


Congratulations! Chapter Finished. Do you want to practice more?
Exercises & Assignments
  • No Content Found.
  • Interview FAQs
  • No Content Found.