Open In App

CSS | 3 Digit Hex Color

Last Updated : 23 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:




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


Output:

Example 2:




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


Output:



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads