Open In App

CSS 6 Digit Hex Color

Last Updated : 09 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The Six Digit Hex Color is very much popular to define colors in CSS because of the variation of multiple colors 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 a hex color code you can get 16 million colors that are the main reason behind the use of hex color codes. 

Syntax:

#RRGGBB

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

Example 1: In this example, we are using the above-explained CSS 6 Digit Hex Color method.

html




<!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: Here is an example of the above method

html




<!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:

 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads