Skip to content
Related Articles

Related Articles

Improve Article
CSS | 6 Digit Hex Color
  • Last Updated : 22 Aug, 2019

The Six Digit Hex Color is very much popular to define colors in CSS because of the variation of multiple colors is available in the 6 digit hex colors codes. There are Six characters followed by a hash(#) like #RRGGBB. The developer used the hex color codes it is hard enough to remember those to compare with color names like blue, green, cyan, brown, etc because color codes contain so many shades of a single color. By using the hex color codes you have a wide-open field to choose your preferable color for your app or site wherever you want to use them. By color’s name, there are 147 names that you can use but by using hex color code you can get 16 million colors that are the main reason behind the using of hex color codes.
Syntax:

#RRGGBB

Note: Here those 6 character define RGB color which is Red, Green and Blue.
Example 1:




<!DOCTYPE html>
<html>
   
<head>
    <title>CSS 6 Digit Hex Color</title>
    <style>
        body {
            background-color: #666600;
        }
           
        h1 {
            color: green;
        }
           
        article {
            background-color: #FFFFFF;
            border: 5px solid green;
            margin: 15px;
            text-align: center;
        }
    </style>
</head>
   
<body>
    <article>
        <h1>GeeksforGeeks</h1>
    </article>
</body>
   
</html>

Output:

Example 2:




<!DOCTYPE html>
<html>
   
<head>
    <title>CSS 6 Digit Hex Color</title>
   
    <style>
        body {
            background-image: url(
            background-attachment: fixed;
            background-size: cover;
        }
           
        h2 {
            color: green;
        }
           
        article {
            background-color: #FFFFFF;
            border: 2px solid green;
            background-position: center center;
            text-align: center;
        }
    </style>
</head>
   
<body>
    <article>
        <h2>GeeksforGeeks</h2>
    </article>
</body>
   
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :