HTML Colors

  • Colors can be used in two ways-
    • Name- By using the name of the color.
    • Hex Code- By using the hex code of the color.


  • These are the main color names in HTML. There are other colors which are not part of HTML or XHTML but they are supported by most of the versions of IE or Netscape.
  • Besides these, you can make any shade of color by creating the hex-code.
  • Hex- for colors



  • Commonly used hex-code is of six digits where-
    • First two digits represent the shade of red.
    • Third and fourth digits represent the shade of green.
    • Last two digits represent the shade of blue.




  • Each digit must be in the hexadecimal range 0 to F (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F).
  • 0 represents the darkest shade while F represents the lightest shade.
  • Hex- code of colors is mandatory to start with a hash (#).
  • Example- #4a3fbb is hex code of its background color.