CSS Color Code

CSS color code values is employed to specify a color. Typically, these area unit accustomed set a color either for the foreground of a part (i.e., its text) instead for the background of the part. positional notation color values contain zero to nine numbers and A to F characters. Decimal values contain zero to 255 numbers.

  • Hexadecimal Value:-

The positional notation price is followed by hash(#).

background:#ffff or #0000 etc.

  • Decimal Value:-

It is takes with a RGB Property.

Note:- RGB suggests that red inexperienced and blue. All colours area unit shaped by mistreatment combination of those 3 colors.

  • Background
  • Color
  • Border

background:rgb(0,0,255) or rgb(255,0,0) etc.

How Color Code Works?

1. Hexadecial Color Code

Syntax:- For background color

div{
        background:#ffff;
        }

Syntax:- For text color

div{
        color:#ffff;
        }

Example:-

Code:- For background color

<!DOCTYPE html>
    <html>
    <head>
        <title>EXample of hexa code color</title>
        <style type="text/css">
          .paracont{
            background: #FF00FF;
            border: 2px solid black;
          } 
          .paracont1{
            background: #0000FF;
            border: 2px solid black; 
          } 
          .paracont2{
            background: #FF0000;
            border: 2px solid black;  
          }  
          
        </style>
    </head>
    <body>
        <h1>Gurukulzone SRCS</h1>
        <p class="paracont">Example of backgound color 
            Using hexadecimal color code.</p>
        <p class="paracont1">Example of backgound color 
            Using hexadecimal color code.</p>
        <p class="paracont2">Example of backgound color 
            Using hexadecimal color code.</p>
    
    </body>
    </html>

Output:-

Code:- For text color

<!DOCTYPE html>
    <html>
    <head>
        <title>Example of hexa code color</title>
        <style type="text/css">
          .paracont{
            color: #FF00FF;
            border: 2px solid black;
          } 
          .paracont1{
            color: #0000FF;
            border: 2px solid black; 
          } 
          .paracont2{
            color: #FF0000;
            border: 2px solid black;  
          }  
          
        </style>
    </head>
    <body>
        <h1>Gurukulzone SRCS</h1>
        <p class="paracont">Example of text color 
            Using hexadecimal color code.</p>
        <p class="paracont1">Example of text color 
            Using hexadecimal color code.</p>
        <p class="paracont2">Example of text color 
            Using hexadecimal color code.</p>
    
    </body>
    </html>

Output:-

2. Decimal Color Code

Syntax:- For background color

div{
        background:rgb(255,0,0);
        }
            

Syntax:- For text color

div{
        color:rgb(255,0,0);;
        }

Example:-

Code:- For backgound color

   <!DOCTYPE html>
    <html>
    <head>
        <title>EXample of decimal value color</title>
        <style type="text/css">
          .paracont{
            background: rgb(218, 165, 32);
            border: 2px solid black;
          } 
          .paracont1{
            background: rgb(150,218,60);
            border: 2px solid black; 
          } 
          .paracont2{
            background: rgb(02, 180, 200);
            border: 2px solid black;  
          }   
          
        </style>
    </head>
    <body>
        <h1>Gurukulzone SRCS</h1>
        <p class="paracont">Example of backgound color 
            Using decimal color code.</p>
        <p class="paracont1">Example of backgound color 
            Using decimal color code.</p>
        <p class="paracont2">Example of backgound color 
            Using decimal color code.</p>
    
    </body>
   <!DOCTYPE html>
    <html>
    <head>
        <title>EXample of decimal value color</title>
        <style type="text/css">
          .paracont{
            background: rgb(218, 165, 32);
            border: 2px solid black;
          } 
          .paracont1{
            background: rgb(150,218,60);
            border: 2px solid black; 
          } 
          .paracont2{
            background: rgb(02, 180, 200);
            border: 2px solid black;  
          }   
          
        </style>
    </head>
    <body>
        <h1>Gurukulzone SRCS</h1>
        <p class="paracont">Example of backgound color 
            Using decimal color code.</p>
        <p class="paracont1">Example of backgound color 
            Using decimal color code.</p>
        <p class="paracont2">Example of backgound color 
            Using decimal color code.</p>
    
    </body>
    </html>

Output:-

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *