Webmaster Papers




Google
 
Web webhostingpapers.com




/pagead2.googlesyndication.com/pagead/show_ads.js">

Hexadecimal Color Notation on the Web


When designing elements for your webpage, you will often be called upon to specify a color. For example, the code for a span shown below specifies that the color of the text within the span will be yellow.

Text

Colors can be specified according to their names, for example "yellow", "green", or "blue". In many cases, these simple color names will work. But what if you want to specify a more sophisticated color like "cornflowerblue"? A particular browser may not recognize a particular color name. It's more reliable to specify colors 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, required to create the color. For example, to create the color cornflowerblue you need red=100, green=149, and blue=237. We could then specify the color of the text within a span using the rgb function as shown below.

Text

This will work fine with style notation, but what if you want to use straight html. Html doesn't recognize the rgb function. In that case, you can specify color using "hexadecimal" notation. Whereas the decimal numbering system uses the characters 0 through 9 to get 10 values, the hexadecimal numbering system uses the characters 0 through f to get 16 values. (After 9 the characters 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 pretty simple but you need two hexadecimal characters to represent all decimal values from 0 to 255. When you increment decimal 9 by 1, you change the 9 to 0 and put 1 in the ten's place. When you increment hexidecimal F by one, you change the F to 0 and put 1 in the "sixteens" place. Sometimes it's not easy to convert between 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 specify the color of text within a span using the hexadecimal notation as shown below.

Text

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

If it's not easy to convert between 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 number after CE? That would be CF. what's the next number after CF? That would be D0. Which hexadecimal number is higher 99 or B2? B2 would be higher than 99. It gets easier with experience.

Here's Java Script code for a simple 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 important to use hexadecimal notation to specify colors when you use DHTML with visual effects, because to create a dynamic color change you have to increment or add a value to a color. The vast amount of color specification on webpages is in hexadecimal notation, so it would be wise to become familiar with it.

Copyright(C) Bucaro TecHelp.

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

About The Author

To learn how to maintain your computer and use it more effectively to design 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

RELATED ARTICLES


Don?t Put Your Slogan in the Title Tag - Optimize Your Web Pages
Don't just put your slogan in the title tag when you formulate the copy of your website. The formulation of the title tag is the most important single aspect when you fine-tune your website:
Integrating Advertising into Your Web Design
If you are going to be placing ads on your website, you'll want to put some thought into how you'll integrate them. Poor integration of ads into your website will cause visitors to click away fast. Successful integration of ads into your site can be highly profitable. Before I show you where to position ads, I want to mention a few important points about ads.
Web Production And Design Tips
You have identified that to have an internet prescence would be of benefit to your small business, however are not sure how to proceed. This article gives free tips on web design services and practices and on how to keep your web designer happy and on side.
Flash Doesnt Always Add Shine to Web Efforts
The trend today to overuse animation in a website's opening pages only serves to confirm that style often overshadows substance. Sometimes a "flash" in the pan ? often courtesy of Macromedia Corp.'s web animation program ? is simply a flash in the pan.
Dont Lose The Sale In The Internets Last Three Feet
In retailing there is a saying that sales are made in the last three feet. What this means is that no matter what you have done with your marketing, the final purchase decision is made when a customer is in-store, with the product in front of them.
Website Design Basic Concepts
So, what's in a website design anyway? And, how do you get a design that is appealing to the broad and varied tastes of all those Internet surfers out there?
Eliciting Constructive Website Feedback
"It's good."
Do-It-Yourself Web Design for Home-Based Businesses
Home-based businesses need a strong web presence to combat the inflated advertising and marketing budgets of their larger competitors, but establishing that presence through a professionally designed and developed web site may not be an affordable option. In many cases, the only cost-effective way to get the web site you want for your business is to do it yourself.
Digitalize It! : (Modification of images with tools such as Adobe CS and Corel)
Then it was a choice among crayons, paints and palettes for an artist and designer to create art. It was a box of crayons that make one happy designer during his early years of formation.
Color Scheme for Your Website?
Yes, in a world that is obsessed with makeover madness, even your website needs to follow specific color guidelines when picking out "what it will wear". The colors you use when designing your website tell an awful lot about your business, though you may not know it.
Web Site Redirection - How to Implement a 301 Redirect
You just created a new web site but want to pass on the search engine rankings of the old one to the new one. What is the most effective and spider/visitor friendly strategy to implement your web site redirection? You should use a 301 redirect.
How To Make It Easy For Your Web Designer To Build Your Website
You have an idea for a website and you are now looking for somebody to build you the site. You want it to be a smooth ride, and want to have a good working relationship with your web designer. You are also looking for a low cost website, so how will you make all of this possible?
Online Businesses Still Ignoring Dial-up Market
In this article you will find the parallel between two Internet connections that makes serious actions trough financial market, leading this to great profits or huge losses.
Your Website Hurts My Eyes: 7 Reasons to Tone Down Your Advertising
So you're on the computer, as usual. Your eyes are smarting. Your back hurts. You want to jump in the car and sail down the highway with all the windows down and your hair flapping in the wind. But before you call it quits for the day, you have to look up just one more thing. Maybe it's web marketing, maybe you want to buy some artwork to hang in your office. Off to Google you go.
Give People What They Want And Watch Your Profits Soar!
Do you know why the majority of people use the Internet?
Speed Up Or Lose Out! How To Improve Your Websites Download Speed
So your web site's online and you've got high rankings in the search engines attracting lots of visitors. But the statistics tell you most of them are leaving after viewing just one page, what's gone wrong?
Custom Website Design - 7 Steps to a More Professional Website
If you are trying to sell a product or service on your website, then it is important to make your site as professional as possible. You might think designing that your own website to look like a professional did so is a rather difficult proposition, however there are many tools online that will help you achieve professional looking design.
How Do We Know When Its Time To Redesign Our Web Site?
A question we frequently get asked is, "how do we know when it is time to redesign our Web site?" The answer undoubtedly varies.
What is ASP.NET
ASP.NET is a new programming framework from Microsoft for developing next generation web Applications. It is a framework built on the Common Language Runtime and introduces a new paradigm to server-side Web development.
Making Good Websites that Stand Out
Websites, there's literally billions of them out there in cyber-space. How many of them do you go to and just think this is boring, bland, or hard to use? It seems like too many to mention. So what makes a good website? I reckon it's about interaction. You've got to make the visitor interested. You've got to grab their attention. Many sites use plenty of bright and shiny gimmicks to attract you, but once you make it through to the content of the site it's just not worthy. A good site uses easy navigation, relevant content, and interactive media like comments and message boards. If you're fortunate, whoever builds your site may even have a few tricks up their sleeves to make it really fun with sound, video, and other interactive fun stuff.