Scanner class Methods in Java

CSS color Property

The color Property


The CSS color property is used to set the color of  text. We can change the color of text to any color.
CSS has several ways of  specifying the colors.At the end you will see an example of changing color of text using inline CSS.

3 Methods to set color in CSS:-

 1.Color Name:-  We can specify the color by using color name. For example, Red, Green,Pink and many more.

Example:- 

HTML Code:-

<body>
<p class="green"> The text inside the paragraph is green</p>
The text outside the paragraph is black(by default).
</body>

CSS Code:-

p.green{
            color: green;
}

Result:

CSS color property example

2.Hexadecimal Values:-  We can specify the color  by using Hexadecimal Code names. Hexadecimal colors are defined by using # as prefix. It has 6 digit. That are hexadecimal values containing numbers from  0 to 9 and alphabets through A to F. For example, #0b5394.

3.RGB :-  RGB is a common color format. It stands for Red,Green,Blue. These three are primary colors.We can specify color value by using frequency of these colors.Each color can have value form  0-255. For example, rgb(0,0,255) means it will print text in green color.

We will see example of both methods below:-

 HTML Code:

<body>
<h1> This is a heading </h1>
<p class="example"> This is a paragraph</p>
</body>

CSS Code:
h1{
     color: #0000FF;
}
p.example{
      color: rgb(255,0,0);
}


Result:

CSS color property example

Inline CSS Example

inline css color property  example


Output:
inline css color example




You can experiment  to learn more about colors in these format.Try it yourself!

Comments