CSS - Colors


CSS - Colors

  • CSS uses color values to specify a color in the web page / website. 
  • Typically, these are used to set a color for an element (i.e., its text). 
  • They can also be used to affect the color of borders and other decorative effects.
  • We can specify the colors in various format.

Format

Syntax

Example

Hex Code

#RRGGBB

p{color:#FF0000;}

RGB Absolute

rgb(rrr,ggg,bbb)

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

keyword

aqua, black, etc.

p{color:blue;}

Attributes :

P //Paragraph
{
    color:#FF0000;

Sample Code :

<!DOCTYPE html>
<html>
    <body>
        <h2
style="color:#00FF00">
            Welcome To Wikitechy
        </h2>
        <h2
style="color:rgb(255, 165, 0)">
            Best E Learning Website In The World
        </h2>
        <h2
style="color:blue;">
            You Can Learn All The Technologies Easily
        </h2>
    </body>
</html>

Code Explanation :


    Here, we are Applying hexadecimal color for h2 tag.

  • Note: RGB values can also be assigned using hexadecimal color values in the form of: #RRGGBB, where RR (red), GG (green) and BB (blue) are hexadecimal values between 00 and FF (same as decimal 0-255).

    Here, h2 element was defined for the statement “Best E-Learning Website In The World” whose RGB Colors values specify its color values based on the formula (red, green, blue).

    <h2 style="color:blue;"> here we are applying blue color for h2 tag .

Output :

 

    Here Hexadecimal color value is applied for Welcome To Wikitechy.

    Over here , the RGB color values is applied for Best E-Learning Website in the World.

    The Text “You Can Learn All the Technologies Easily” will appear in blue color.