A comprehensive guide to web safe colors, including their history, technical specifications, and modern relevance in web design and development.
Web safe colors refer to a palette of 216 colors that were considered "web safe" in the early days of web development. These colors were designed to display consistently across different computer systems with limited color capabilities, ensuring that websites would appear as intended regardless of the user's hardware.
In the mid-1990s, when the World Wide Web was gaining popularity, many computer systems were limited to displaying only 256 colors (8-bit color). Of these 256 colors:
Web designers needed a reliable set of colors that would render consistently across different systems without dithering (the process of approximating unavailable colors by mixing available colors, resulting in a speckled appearance).
The web safe palette was created by using all possible combinations of the following RGB values:
This created 6 × 6 × 6 = 216 distinct colors. These RGB values correspond to hexadecimal values of 00, 33, 66, 99, CC, and FF.
/* The 216 web safe colors can be generated with this pattern */
const webSafeValues = [0, 51, 102, 153, 204, 255];
const webSafeColors = [];
for (let r of webSafeValues) {
for (let g of webSafeValues) {
for (let b of webSafeValues) {
const hex = `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`.toUpperCase();
webSafeColors.push(hex);
}
}
}
// This generates all 216 web safe colors, from #000000 to #FFFFFFWeb safe colors can be expressed in several formats:
The most common format uses hexadecimal values where each color channel (R, G, B) can only have values of 00, 33, 66, 99, CC, or FF:
/* Examples of web safe colors in hexadecimal notation */
#000000 /* Black */
#FF0000 /* Red */
#00FF00 /* Green */
#0000FF /* Blue */
#FFFF00 /* Yellow */
#00FFFF /* Cyan */
#FF00FF /* Magenta */
#FFFFFF /* White */In RGB notation, each channel can only have values of 0, 51, 102, 153, 204, or 255:
/* Examples of web safe colors in RGB notation */
rgb(0, 0, 0) /* Black */
rgb(255, 0, 0) /* Red */
rgb(0, 255, 0) /* Green */
rgb(0, 0, 255) /* Blue */
rgb(255, 255, 0) /* Yellow */
rgb(0, 255, 255) /* Cyan */
rgb(255, 0, 255) /* Magenta */
rgb(255, 255, 255)/* White */Web safe colors can also be expressed as percentages, where each channel can only have values of 0%, 20%, 40%, 60%, 80%, or 100%:
/* Examples of web safe colors in percentage notation */
rgb(0%, 0%, 0%) /* Black */
rgb(100%, 0%, 0%) /* Red */
rgb(0%, 100%, 0%) /* Green */
rgb(0%, 0%, 100%) /* Blue */
rgb(100%, 100%, 0%) /* Yellow */
rgb(0%, 100%, 100%) /* Cyan */
rgb(100%, 0%, 100%) /* Magenta */
rgb(100%, 100%, 100%) /* White */The web safe palette has several mathematical properties:
To check if a color is web safe:
/* Function to check if a color is web safe */
function isWebSafeColor(r, g, b) {
const webSafeValues = [0, 51, 102, 153, 204, 255];
return (
webSafeValues.includes(r) &&
webSafeValues.includes(g) &&
webSafeValues.includes(b)
);
}For colors that aren't web safe, you can find the nearest web safe equivalent:
/* Function to find the nearest web safe color */
function getNearestWebSafeColor(r, g, b) {
// Round each component to the nearest web safe value
const webSafeR = Math.round(r / 51) * 51;
const webSafeG = Math.round(g / 51) * 51;
const webSafeB = Math.round(b / 51) * 51;
// Ensure values don't exceed 255
return {
r: Math.min(255, webSafeR),
g: Math.min(255, webSafeG),
b: Math.min(255, webSafeB)
};
}Web safe colors are often organized in charts or grids for easy reference:
Web safe colors significantly influenced early web design:
Several factors led to the declining relevance of web safe colors:
While strict adherence to the web safe palette is no longer necessary, the concept still has some relevance:
/* Example of using web safe colors for a retro design */
.retro-container {
background-color: #000000;
color: #00FF00; /* Classic "green screen" look */
}
.retro-button {
background-color: #0066FF;
color: #FFFFFF;
border: 2px solid #00CCFF;
}Modern CSS provides several ways to work with colors, including web safe ones:
/* Different ways to specify web safe colors in CSS */
/* Hexadecimal notation */
.element1 {
color: #00CCFF;
}
/* RGB notation */
.element2 {
color: rgb(0, 204, 255);
}
/* RGB percentage notation */
.element3 {
color: rgb(0%, 80%, 100%);
}
/* Named colors (some correspond to web safe colors) */
.element4 {
color: aqua; /* Same as #00FFFF */
}Some web safe colors have standard names in CSS:
| Color Name | Hex Value | RGB Value |
|---|---|---|
| black | #000000 | rgb(0, 0, 0) |
| silver | #C0C0C0 | rgb(192, 192, 192) |
| gray | #808080 | rgb(128, 128, 128) |
| white | #FFFFFF | rgb(255, 255, 255) |
| maroon | #800000 | rgb(128, 0, 0) |
| red | #FF0000 | rgb(255, 0, 0) |
| purple | #800080 | rgb(128, 0, 128) |
| fuchsia | #FF00FF | rgb(255, 0, 255) |
| green | #008000 | rgb(0, 128, 0) |
| lime | #00FF00 | rgb(0, 255, 0) |
| olive | #808000 | rgb(128, 128, 0) |
| yellow | #FFFF00 | rgb(255, 255, 0) |
| navy | #000080 | rgb(0, 0, 128) |
| blue | #0000FF | rgb(0, 0, 255) |
| teal | #008080 | rgb(0, 128, 128) |
| aqua | #00FFFF | rgb(0, 255, 255) |
Note that not all of these named colors are strictly web safe according to the 216-color palette definition, but they are part of the standard 16 HTML color names.
When using web safe or any colors in web development, accessibility should be considered:
/* Example of accessible use of web safe colors */
.accessible-text {
/* High contrast combination of web safe colors */
background-color: #000000; /* Black background */
color: #FFFF00; /* Yellow text */
/* Add non-color indicators for important elements */
border: 2px solid #FFFFFF;
text-decoration: underline;
}Modern web development has moved beyond web safe colors to more sophisticated color management:
Modern websites often implement multiple color schemes:
/* Example of implementing light and dark modes */
:root {
/* Light mode (default) */
--background: #FFFFFF;
--text: #000000;
--accent: #0066CC;
}
@media (prefers-color-scheme: dark) {
:root {
/* Dark mode */
--background: #000000;
--text: #FFFFFF;
--accent: #33CCFF;
}
}Modern web development often uses design systems with color tokens rather than hard-coded colors:
/* Example of a color token system */
:root {
/* Primary colors */
--color-primary-100: #CCE5FF;
--color-primary-200: #99CCFF;
--color-primary-300: #66B2FF;
--color-primary-400: #3399FF;
--color-primary-500: #0066CC; /* Web safe */
--color-primary-600: #0052A3;
--color-primary-700: #003D7A;
/* Semantic tokens */
--color-action: var(--color-primary-500);
--color-action-hover: var(--color-primary-600);
--color-action-active: var(--color-primary-700);
}Explore these comprehensive pillar articles related to Web Safe Colors
A comprehensive guide to color theory, its fundamental principles, and practical applications in digital design and web development.
Comprehensive guide to complementary colors - opposing hues on the color wheel that create maximum visual contrast, dynamic tension, and powerful design impact through scientific color relationships and perceptual phenomena.
Comprehensive guide to analogous color schemes - adjacent hues on the color wheel that create natural harmony, visual cohesion, and sophisticated design solutions through subtle color relationships and graduated transitions.
Comprehensive guide to triadic color schemes - three colors evenly spaced around the color wheel that create balanced, vibrant, and dynamic visual compositions with mathematical precision and artistic appeal.
Discover more about Web Safe Colors and related color theory concepts
A comprehensive guide to color theory, its fundamental principles, and practical applications in digital design and web development.
Comprehensive guide to analogous color schemes - adjacent hues on the color wheel that create natural harmony, visual cohesion, and sophisticated design solutions through subtle color relationships and graduated transitions.
Comprehensive guide to complementary colors - opposing hues on the color wheel that create maximum visual contrast, dynamic tension, and powerful design impact through scientific color relationships and perceptual phenomena.
A comprehensive guide to monochromatic color schemes - sophisticated single-hue harmonies that create unified visual experiences through systematic variations in saturation, lightness, and tonal relationships, essential for elegant design compositions, brand consistency, and advanced color theory applications requiring cohesive aesthetic unity.
A comprehensive guide to split-complementary color schemes - sophisticated three-color harmonies that combine a base color with two colors adjacent to its complement, creating balanced visual contrast with reduced tension compared to direct complementary pairs, essential for refined design compositions, brand identity systems, and advanced color theory applications.
A comprehensive guide to tetradic color schemes - sophisticated four-color harmonies that use two complementary pairs arranged in rectangular or square formations on the color wheel, providing maximum color variety while maintaining structured relationships essential for dynamic design compositions, brand systems, and advanced color theory applications.
Discover more color terminology and concepts in our comprehensive glossary.
Browse Full Glossary