HTML - HEX Colors



HTML HEX colors are used to define web page colors with hexadecimal values, a number system utilizing 16 symbols: 0-9 and A-F.

HEX Color Codes in HTML

Each HEX color code starts with a hash sign (#) and includes six digits. The first two digits specify the red component, the next two indicate the green component, and the final two represent the blue component. This method allows precise color customization for web design.

To use hex colors in HTML, we can either assign them directly to an element using the style attribute, or define them in a style tag or sheet using the color property.

<element style="color: #FFFFFF;">

Hexadecimal Color Codes

Following is a list of few colors using hexadecimal notation:

Color Color HEX
  #000000
  #FF0000
  #00FF00
  #0000FF
  #FFFF00
  #00FFFF
  #FF00FF
  #C0C0C0
  #FFFFFF

Examples of HTML Hex Colors

Here are some example that shows how to use Hexadecimal Colors in HTML pages.

Setting Background Color for Body

Here is an example to set background of HTML tags by color code in hexadecimal.

<!DOCTYPE html>
<html>
<head>
   <title>
      HTML Colors by HEX code
   </title>
</head>
<body style="background-color: #00FF00;">
   <p>
      Use different color code for body 
      and table and see the result. 
   </p>
   
   <p style="color: #FFFFFF;">
      This text will appear white on 
      black background. 
   </p>
</body>
</html>

Setting Color on Table Cells

This is another example that demonstrates use of HEX code.

<!DOCTYPE html>
<html>
<head>
   <title>
      HTML HEX Color code
   </title>
</head>
<body style="width:300px; height:100px;">
   <h2 style="background-color: #FF6666;">
      Setting the Background using HEX Code 
   </h2>
   <table style="background-color: #FF3335;">
      <tr>
         <td style="color: #FFFFFF;">
               The text color of the paragraph is 
               styled using HEX code.
         </td>
      </tr>
   </table>
</body>
</html>

Conclusion

Selecting right colors for designing a webpage is difficult. Even if you have a color in your mind, You need to make a computer understand hexadecimal value of color. To make your job easier we suggests using our HTML color picker tool.

Advertisements