HTML Colors

HTML Colors

HTML Colors are the colors used in HTML (Hypertext Markup Language) documents to style the appearance of web pages. Colors are an important aspect of web design as they help to make a website visually appealing and engaging.

There are various ways to specify colors in HTML, including using color names, hexadecimal codes, RGB (Red, Green, Blue) values, and more. Each method has its own syntax for specifying colors.

Hexadecimal Codes:

Hexadecimal codes represent colors using a combination of six numbers and letters. For example, the color white is represented by #FFFFFF and black is represented by#000000. Other colors have their own unique hexadecimal codes.

Here are some examples of hexadecimal codes and their corresponding colors:

  • #000000 - Black
  • #FFFFFF - White
  • #FF0000 - Red
  • #00FF00 - Green
  • #0000FF - Blue
  • #FFFF00 - Yellow
  • #FF00FF - Magenta
  • #00FFFF - Cyan
Example
<!DOCTYPE html>
<html>
<head>
   <title>Hexadecimal color</title>
</head>
<body text = "#FFFF00" bgcolor = "#0000FF">
   <h2>Defferent color Hexadecimal codes</h2>
   <table bgcolor ="#00FF00">
      <tr>
         <td color="#FFFFFF">Favourite Icon</td>
      </tr>
   </table>    
</body>
</html>

RGB Values:

RGB values refer to the combination of red, green, and blue values that make up a color. Each value can range from 0 to 255, and the three values are separated by commas. For example, the color white has an RGB value of (255, 255, 255), while black has an RGB value of (0, 0, 0).

Here are some examples of RGB values and their corresponding colors:

  • rgb(0, 0, 0) - Black
  • rgb(255, 255, 255) - White
  • rgb(255, 0, 0) - Red
  • rgb(0, 255, 0) - Green
  • rgb(0, 0, 255) - Blue
  • rgb(255, 255, 0) - Yellow
  • rgb(255, 0, 255) - Magenta
  • rgb(0, 255, 255) - Cyan
Example
<!DOCTYPE html>
<html>
<head>
    <title>RGB Color</title>
</head>
<body text = "rgb(0, 0, 0)" bgcolor = "rgb(0, 255, 0)">
    <h2>Defferent color RGB codes</h2>
    <table bgcolor ="rgb(255, 255, 0)">
            <tr>
                <td color="rgb(255, 255, 255)">Favourite Icon</td>
            </tr>
    </table>    
</body>
</html>

Color Names:

HTML Color Names are a set of predefined color names that can be used in HTML and CSS documents. These color names provide a convenient way to specify colors using easy-to-remember words rather than numerical values such as hexadecimal or RGB codes.

Here is a list of the standard HTML color names along with their corresponding color: aqua , black, fuchsia, gray, green, lime, maroon, navy, orange, red, silver, white,yellow etc.

Example
<!DOCTYPE html>
<html>
<head>
   <title>Color Name</title>
</head>
<body text = "green" bgcolor = "yellow">
   <h2>Defferent color RGB codes</h2>
   <table bgcolor ="black">
      <tr>
         <td color="white">Favourite Icon</td>
      </tr>
   </table>    
</body>
</html>

HTML color codes are an important part of web design and can be used to create visually appealing and engaging websites.

Previous
HTML - Lists
Next
HTML Links - In Depth details with Practical example of HTML Links