Syntax of RGB color code is rgb(rr,gg,bb)
As an example to show green color using RGB code we can write as following, rgb(0,255,0)
You can get RGB code of a color by using “Adobe Photoshop” or any image processing software. But in HTML we us corresponding hexadecimal value of a RGB color code.
Example : for red color
- RGB value = (255,0,0)
- Hex value = #ff0000
But most web browsers support 17 main colors.
They are
- Aqua
- Black
- Blue
- Fuchsia
- Gray
- Green
- Lime
- Maroon
- Navy
- Olive
- Orange
- Purple
- Red
- Sliver
- Teal
- White
- Yellow
We can use following HTML code
<HTML>
<HEAD>
<TITLE>Colors</TITLE>
</HEAD>
<BODY>
<H1><FONT color=”red”>This is in red color</FONT></H1>
<H2><FONT color=#0000FF >This is in green</FONT></H2>
<P><FONT color=”blue”>This is some text</FONT></P>
</BODY>
</HTML>
The output will be,
How to use background colors.
<HTML>
<HEAD>
<TITLE>Colors</TITLE>
</HEAD>
<BODY BGCOLOR=”orange”>
<H1><FONT color=”red”>This is in red color</FONT></H1>
<H2><FONT color=#0000FF >This is in green</FONT></H2>
<P><FONT color=”blue”>This is some text</FONT></P>
</BODY>
</HTML>
output,
<HTML>
<HEAD>
<TITLE>Colors</TITLE>
</HEAD>
<BODY BGCOLOR=”orange”>
<H1><FONT color=”red”>This is in red color</FONT></H1>
<H2><FONT color=#0000FF >This is in green</FONT></H2>
<P><FONT color=”blue”>This is some text</FONT></P>
</BODY>
</HTML>
output,