- Get link
- X
- Other Apps
The color Property
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:-
HTML Code:-
<body>
<p class="green"> The text inside the paragraph is green</p>
The text outside the paragraph is black(by default).
</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:
We will see example of both methods below:-
HTML Code:
color: green;
}
Result:
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.
HTML Code:
<body>
<h1> This is a heading </h1>
<p class="example"> This is a paragraph</p>
</body>
You can experiment to learn more about colors in these format.Try it yourself!
Comments
Post a Comment
If you have any doubt, ask here