Color-Tag

Colors are very important to give a good look and feel to your website. You can specify colors on page level using <body> tag or you can set colors for individual tags using bgcolor or clolor attribute.

HTML Color Coding Methods

There are following three different methods to set colors in your web page −
1) Color names − You can specify color names directly like green, blue or red.
2) Hex codes − A six-digit code representing the amount of red, green, and blue that makes up the color.
3) Color decimal or percentage values − This value is specified using the rgb( ) property.


Two ways to set colors
1)foreground color
2)background color

Foreground color

Foreground color is used to change the color of an element's text. Foreground color is specified like this color:orange; . Foreground color can also (indirectly) affect the color of other parts of the element, including its border.

Example

<html>
<head>
<title>color</title>
</head>
<body>
<p style="color:red">i am color tag </p>
</body>
</html>

Output

i am color tag

background-color

The attribute that is used to set background color of an HTML element is bgcolor. The bgcolor attribute can be used with the following tags- body, table, td, th, tr, marquee.

Example

<html>
<head>
<title>color</title>
</head>
<body bgcolor="pink">
<p >i am bgcolor tag </p>
</body>
</html>

Output

color

Example

<html>
<head>
<title>color</title>
</head>
<body bgcolor="lavender">
<p style="color:#c0c0c0">HTML-hyper text markup language </p>
</body>
</html>

Output

color1