Full width home advertisement

How To

Science

Post Page Advertisement [Top]


HTML Color Coding Methods
There are three different methods we can use to set colors in a web page:

1. Color names - You can set 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. E.g #0000FF - blue, #00FF00 - green and #FF0000 – red.

3. Color decimal or percentage values - This value is specified using the rgb() property.E.g rgb(255,0,0) – red, rgb(0,255,0) – green and rgb(0,0,255) – blue.


HTML Color

The HTML Color attribute can be used to set colors on webpage with different tags like <body> or with individual tags like <font>, <span> etc using the bgcolor or color attributes.

The <body> tag has following attributes which can be used to set different colors:

1. bgcolor - sets a color for the background of the webpage.

2. text - sets a color for the body text.

3. alink - sets a color for active links or selected links.

4. link - sets a color for linked text.

5. vlink - sets a color for visited links – i.e, for linked text that you have already clicked on.


HTML Colors - Color Names

You can use a direct color name to set text or background color. This means you can use the most common color names to specify colors for a webpage. E.g red, green, blue etc

Note: Not all colors can be set using color names

Example of Color Names

<!DOCTYPE html>

<html>

<head>

<title>Scholar HTML Color Names</title>

</head>

<body text="blue" bgcolor="green">

<p>Use different color names for body and table </p>

<table bgcolor="black">

<tr>

<td>

<font color="white">This text will appear white on black background.</font>

</td>

</tr>

</table>

</body>

</html>


HTML Colors - Hex Codes

A hexadecimal is a 6 digit representation of a color. The first two digits(RR) represent a red value, the next two are a green value(GG), and the last are the blue value(BB).

A hexadecimal value can be taken from any graphics software like Adobe Fireworks, Adobe Photoshop, MS Paint or even HTML Editor like Adobe Dreamweaver. 
E.g #0000FF - blue, #00FF00 - green and #FF0000 – red.

Each hexadecimal code will be followed by a hash sign #.

Example

<!DOCTYPE html>

<html>

<head>

<title>Scholars HTML Colors by Hex</title>

</head>

<body text="#0000FF" bgcolor="#00FF00">

<p>Use different color hexa for for body and table and see the result.</p>

<table bgcolor="#000000">

<tr>

<td>

<font color="#FFFFFF">This text will appear white on black background.</font>

</td>

</tr>

</table>

</body>

</html>



HTML Colors - RGB Values

This color value is specified using the rgb( ) property. The property takes three values, one each for red, green, and blue. The value can be an integer between 0 and 255 or a percentage.

Note: Not all browsers support rgb() property of color so it is advised not to use it always.

Example
Here are the examples to set background of an HTML tag by color code using rgb() values:

<!DOCTYPE html>

<html>

<head>

<title>Scholars HTML Colors by RGB code</title>

</head>

<body text="rgb(0,0,255)" bgcolor="rgb(0,255,0)">

<p>Use different color code for for body and table and see the result.</p>

<table bgcolor="rgb(255,0,255)">

<tr>

<td>

<font color="rgb(255,255,255)">This text will appear white on black background.</font>

</td>

</tr>

</table>

</body>

</html>

No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib