CSS | 3 Digit Hex Color

The 3 Digit Hex Color code is similar to 6 Digit Hex Color it’s shorthand for 6 Digit Hex Color. In 3 Digit Hex Color shrink into single character those have twins in 6 Digit Hex Color the effect will be same but reduce the color variant. The 3 Digit Hex Color contains 3 character followed by hash(#) like #RGB. The #RGB define Red, Green and Blue component.
Syntax:

#RGB

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

Example 2:



filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.