raphics are a common way of bringing color into a Web site. Your create your images using your favorite editor, test your color palette on different browsers/platforms, and drop the images into your page. Optimizing Graphicsteaches you how to create high-impact, low-bandwidth images for Web use.
Code, be it through stylesheets or directly within HTML, lets you set display colors directly. Typically you’ll use a code-based solution for backgrounds and text colors. Remember, with CSS, you can do many of the text treatments you would once have done only with inserted graphics.
Color Palettes and GIFs
When you’re talking about palettes and graphic files, the term takes on a slightly different meaning from the design palette.
A palette is the set of colors that you are using. In your design palette, you’ll have maybe three or six colors, selected for the way they work with each other and with the content of your site. As you make your design palette decisions, you might be referring to a color wheel and selecting, say, a triad relationship plus three saturations of each.
As you move into production, this palette must convert to a palette that can be displayed by the computer—that is, it must be displayed using an RGB model, the model that monitors use. Each color will be represented by the amount of red, green, and blue it contains.
With indexed images, like GIFs, this process goes one step further. Each image is indexed to a table of 256 or fewer color palette. This type of palette is also known as a color lookup table. But wait, you say, I have only six colors! Ah, with variations of hue and saturation, not to mention anti-aliasing and edge smoothing and other techniques, your original six colors can quickly become dozens.
You’ll save each indexed image file along with its palette, aka, color lookup table. As you save, you can select the type of color lookup table you want to use: adaptive, Web safe, or system. In theory, Web safe contains only colors which are displayable in all browsers on all platforms. In general practice, we find the adaptive palette will give you the best results.
Specifying Color for the Web
You specify color using color names, hex values, or RGB values.
Web pages are viewed on a monitor, so the text and images used in a design will always be displayed in RGB (additive) color. RGB colors are specified by a value that describes the amount of red, green, and blue the color contains. Each primary element in a color can be represented as a number between 0 and 255, resulting in millions of possible combinations of red, green, and blue, like this:
Red Value |
Green Value |
Blue Value |
|
![]() |
0 | 85 | 210 |
![]() |
77 | 226 | 33 |
![]() |
255 | 223 | 34 |
![]() |
236 | 49 | 210 |
There are four ways to represent these color values to a Web browser:
- By color name, using a common lookup table;
- By hexadecimal (hex) representation of colors, in which values are converted to base 16 where counting is done 0-9 then A-F.
- By RGB value (CSS)
- By RGB percentages (CSS)
For example, here’s some aqua text on a black background:
AQUA TEXT! |
The same two colors can be described as:
- “aqua” and “black”
- #00ffff and #000000
- 00,255,255 and 0,0,0
- 0%,100%,100% and 0%,0%,0%
Using Color Names
One way to specify color is by using a set of predefined color names.
The most intuitive way to call a color in a Web page is by its name: “red” or “wheat,” for example. The color names date back to old UNIX standards.
When you use a color name as an attribute, make sure you surround it with quotation marks to make it HTML and XML compliant, but be sure you’re nesting single and double quotes correctly. For example, this uses inline CSS to set a background color value of “black” and a text color of “aqua.” Note the use of nested single and double quote marks:
This is a td element with color and background colors set via CSS. If you don’t see the effect, your browser isn’t CSS-compliant. |
This chart shows the standard names. Click on the alphabet example beside each color name to turn the background the specified color.
Click here to go to HTML Basics: Choosing a Color
Specifying Color Using Hex Values
Another way to specify color is using hexadecimal values.
Hexadecimal (hex) representation of colors using a numerical system to describe the red, green, and blue values. Instead of using a 0 to 255 scale, the hex system converts the values to base 16 where counting is done 0-9 then A-F. The result is a six character value, ranging from #000000 (black) to #ffffff (white).
The chart below show how these hex values relate to our familiar base 10 system:
Base 10 | 0 | 1 | 10 | 12 | 15 | 16 | 17 | 26 | 31 | 32 | 153 | 159 | 160 | 189 | 204 | 255 |
Hexadecimal | 0 | 1 | A | C | F | 10 | 11 | 1A | 1F | 20 | 99 | 9F | A0 | BD | CC | FF |
Hex colors are represented by a 2 digit value for each primary. It is possible to create the same millions of combinations of RGB using hex values.
A color that would be specified at R=0, G=85, B=210 is written in hexadecimal as 0055D2. The first two digits are the red value, the third and forth digits are the green value, and the last digits are the blue value.
You specify hex values by typing a # and the six digit value:
{color: #rrggbb}
For example, this code sets the foreground and background color for a table cell using inline CSS styles and hex values:
This is a td element with color and background colors set via CSS. If you don’t see the effect, your browser isn’t CSS-compliant. |
Using RGB Values
Another way to specify color is by the percentage of red, green, and blue it contains or by the numerical values of red, green, and blue it contains.
You can use either percentage values or numerical values of the red, green, and blue components to specify color. RGB values work with CSS, but will not work with the (soon to be obsolete anyway) font tag.
Fireworks image editing software converts the 0 to 255 values of raw RGB models into a scale of 0-100%, where 100% is equal to 255.
You specify RGB percentage values by typing the letters rgb, an open parenthesis, the three percentages, and a close parenthesis:
{color: rgb(0%, 10%, 60%)}
For example, this code sets the foreground and background color for a table cell using inline CSS styles and RGB percentages:
This is a td element with color and background colors set via CSS. If you don’t see the effect, your browser isn’t CSS-compliant. |
You can also specify RGB values as a decimal number. PhotoShop describes color as a decimal number. To use a decimal number value, type the letters rgb, an open parenthesis, the three numbers separated with a comma, and a close parenthesis, like this:
{color: rgb(255, 0, 0)}
For example, this code sets the foreground and background color for a table cell using inline CSS styles and RGB decimal values:
This is a td element with color and background colors set via CSS. If you don’t see the effect, your browser isn’t CSS-compliant. |
“Web-safe” Colors
“Web-safe” colors are the 216 colors that are supported by all browsers and platforms.
Web Safe colors are a subset of the millions of possible colors between 000000 (black) and FFFFFF (white). Some people prefer to use only these 216 colors on a Web page because they feel only these colors can accurately be represented across all platforms and browsers.
Web-safe colors have six possible RGB hex values: 00, 33, 66, 99, CC, and FF. These six values can combine to form 216 colors. If you remember these six hex values, it is easy to tell whether a color is “Web safe” or not. 6633CC is a Web safe color; and 05F211 is not. 66 and 33, and CC are acceptable values; 05, F2, and 11 are not.
Choosing Web safe colors by specifying a value such as FF3399, is not very intuitive, so most software uses a color palette like this one from Fireworks, which give a visual representation of the Web safe colors. Click on the color you want to use and the Web safe hex color value is selected. Some image editing software also has a “snap to” function that will allow you to mix any color and then it converts it to the nearest Web safe color from the 216 palette.
Viewer Variation
Your readers won’t see colors exactly as you do.
Getting “accurate” color on the web is difficult to impossible, as so many variations are involved. Your best bet is to select colors that work, then test them under as many different variations as possible. Even then, you’ll still have perception differences; biologically, different people perceive colors differently.
But testing can help a lot. First, try viewing your pages under a 256 color monitor. Although increasing numbers of readers have true-color monitors, this is one place where you will still find some variation.
To simulate a basic color monitor, change your monitor’s color setting to 256 colors. On a Macintosh, use the “Monitors and Sounds” control panel:
On a PC use the Setting/Control Panel/Display option, then select the Settings tab/256 color option:
If you look at your images in 256 color mode, you’ll get a better sense of what your readers are seeing.
Next, try viewing your page under both Netscape Navigator and Internet Explorer. There is a fairly even mix of these browsers in use, and each has some subtle variations.
Finally, if you have access to Macintosh, PC, and UNIX machines, try viewing your page on the different platforms. You will see system-to-system differences in rendering.


Data Observability Explained
Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the


Logitech G502 Software: Optimize and Customize Your Gear
One of the most significant surges of the 21st century is gaming. Gaming is more popular than ever before thanks to innovative new consoles, high-tech PC setups, mobile gaming improvements,


Different Types of Data Models Explained with Examples
In the modern world, data is everything and everywhere. With so much access to technology, data has become a valuable resource for any business. Albeit a complex one. Data is


Revolutionizing Search: A Glimpse Into Google’s Generative Experience
Google is revolutionizing the search experience as we know it with its latest generative experience. No longer will you be bound by the limitations of traditional keyword searching. Now, you


10 Productivity Hacks to Supercharge Your Business in 2023
Picture this: your team working seamlessly, completing tasks efficiently, and achieving goals with ease. Sounds like too good to be true? Not at all! With our productivity hacks, you can


GM Creates Open Source uProtocol and Invites Automakers to Adopt It: Revolutionizing Automotive Software Development.
General Motors (GM) recently announced its entry into the Eclipse Foundation. The Eclipse Foundation is a prominent open-source software foundation. In addition, GMC announced its contribution of “uProtocol” to facilitate


What is Metadata?
What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular


What We Should Expect from Cell Phone Tech in the Near Future
The earliest cell phones included boxy designs full of buttons and antennas, and they only made calls. Needless to say, we’ve come a long way from those classic brick phones


The Best Mechanical Keyboards For Programmers: Where To Find Them
When it comes to programming, a good mechanical keyboard can make all the difference. Naturally, you would want one of the best mechanical keyboards for programmers. But with so many


The Digital Panopticon: Is Big Brother Always Watching Us Online?
In the age of digital transformation, the internet has become a ubiquitous part of our lives. From socializing, shopping, and learning to more sensitive activities such as banking and healthcare,


Embracing Change: How AI Is Revolutionizing the Developer’s Role
The world of software development is changing drastically with the introduction of Artificial Intelligence and Machine Learning technologies. In the past, software developers were in charge of the entire development


The Benefits of Using XDR Solutions
Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved