Web-design informational articles

Hexadecimal color notation on the web - web-design


When deceitful essentials for your webpage, you will often be called upon to give a color. For example, the code for a span shown below specifies that the color of the text in the span will be yellow.


Colors can be individual according to their names, for case "yellow", "green", or "blue". In many cases, these austere color names will work. But what if you want to detail a more clever color like "cornflowerblue"? A detail browser may not acknowledge a exact color name. It's more steadfast to give ensign with an "RGB triplet".

An RGB triplet specifies a color based upon the amounts of red, green, and blue, on a scale from 0 to 255, necessary to construct the color. For example, to build the color cornflowerblue you need red=100, green=149, and blue=237. We could then give the color of the text surrounded by a span using the rgb act as shown below.


This will work fine with style notation, but what if you want to use above-board html. Html doesn't acknowledge the rgb function. In that case, you can detail color using "hexadecimal" notation. But the decimal numbering coordination uses the font 0 because of 9 to get 10 values, the hexadecimal numbering classification uses the lettering 0 by means of f to get 16 values. (After 9 the font a, b, c, d, e and f are used, as shown below. )

Decimal Hexidecimal Equivilants

dec hex

0 = 0

1 = 1

2 = 2

3 = 3

4 = 4

5 = 5

6 = 6

7 = 7

8 = 8

9 = 9

10 = A

11 = B

12 = C

13 = D

14 = E

15 = F

On first appearance, this looks beautiful clean but you need two hexadecimal typescript to characterize all decimal ethics from 0 to 255. When you increment decimal 9 by 1, you adjust the 9 to 0 and put 1 in the ten's place. When you increment hexidecimal F by one, you alter the F to 0 and put 1 in the "sixteens" place. At times it's not easy to change among decimal and hexadecimal in your head.

RGB Triplet for Cornflowerblue

color dec hex

red 100 64

green 149 95

blue 237 ED

We could then detail the color of text surrounded by a span using the hexadecimal notation as shown below.


Note that when we designate the use of hexadecimal notation by insertion a pound (#) sign in front of the number, and we don't use commas to break the color components.

If it's not easy to alter among decimal and hexadecimal in your head, then how do you do it? You can use a calculator that has a decimal to hexadecimal coversion function, or you can learn to think in hexadecimal. For example, what's the next come to after CE? That would be CF. what's the next come to after CF? That would be D0. Which hexadecimal amount is advanced 99 or B2? B2 would be senior than 99. It gets easier with experience.

Here's Java Lettering code for a clean decimal to hexidecimal color converter

function convert(decvalue)


var num = parseInt(decvalue);

if(num >= 0 && num < 256)


var hexnum = num. toString(16);

alert("#" + hexnum);


else {alert("Error!");}


It's central to use hexadecimal notation to give flag when you use DHTML with visual effects, as to conceive a dynamic color adjust you have to increment or add a value to a color. The vast total of color specification on webpages is in hexadecimal notation, so it would be wise to befall customary with it.

Copyright(C) Bucaro TecHelp.

Permission is arranged for the below critique to forward, reprint, distribute, use for ezine, newsletter, website, offer as free bonus or part of a creation for sale as long as no changes are made and the byline, copyright, and the source box below is included.

About The Author

To learn how to avow your laptop and use it more in actual fact to blueprint a Web site and make money on the Web visit bucarotechelp. com. To subscribe to Bucaro TecHelp Newsletter visit http://bucarotechelp. com/search/000800. asp


Check1st Web Accessibility Testing Tool  Facility Executive Magazine

Color Schemes for Web Design  University Herald

Developed by:
home | site map
goldenarticles.net © 2021