Baumeister Mediasoft Engineering BME - Baumeister Mediasoft Engineering  JavaScript Application: Display Web-safe Colors - English Version JavaScript-Anwendung: Websichere Farben anzeigen - Deutsche Version
Baumeister Mediasoft Engineering
Bartels AutoEngineerCarLogServicesResourcesCompany ProfileContact Us
Baumeister Mediasoft Engineering » Resources » Web Development » JavaScript » Applications » Display Web-safe Colors
JavaScript Applications

JavaScript Application: Display Web-safe Colors

Baumeister Mediasoft Engineering

Web-safe color codes include the following RGB values:

  • 0x00
  • 0x33
  • 0x66
  • 0x99
  • 0xCC
  • 0xFF

The following JavaScript generates a table for displaying the websafe colors:

<script type="text/javascript">
<!--
//--><![CDATA[//><!--
// Color code table
= new Array('00''33''66''99''cc''ff');
// Start color table
'<table border="1" cellpadding="6" style="border-collapse:collapse;">';
// Iterate red color
for (06r++)
{
    
// Iterate green color
    
for (06g++)
    {
        
// Start color table row
        
+= '<tr>';
        
// Iterate blue color
        
for (06b++)
        {
            
// Get RGB (background) color code
            
'#' c[r] + c[g] + c[b];
            
// Get alternative/tooltip text
            
' = RGB('
                
parseInt('0x' c[r]) + ', '
                
parseInt('0x' c[g]) + ', '
                
parseInt('0x' c[b]) + ')'
                
;
            
// Get "inverted" RGB (foreground) color code
            
'#' c[r] + c[g] + c[b];
            
// Color table cell
            
+= '<td align="center"'
                
' style="'
                
'background-color:' ';'
                
'color:' ';'
                
'font-family:Courier New;'
                
'cursor:hand;'
                
'"'
                
' title="' '"'
                
' onclick="alert(\'' '\');"'
                
' onmouseover="window.status=\'' '\';"'
                
' onmouseout="window.status=\' \';"'
                
'>' '</td>'
                
;
        }
        
// End color table row
        
+= '</tr>';
    }
}
// Display color table
document.write('</table>');
//--><!]]>
</script>

Output/Display

Related Topics

Baumeister Mediasoft Engineering » Resources » Web Development » JavaScript » Applications » Display Web-safe Colors

JavaScript Application: Display Web-safe Colors • © 2025 Manfred Baumeister • Updated: 29 October 2008, 14:15:01 GMT

Baumeister Mediasoft Engineering, Clontarf, Dublin 3, D03 HA22, Ireland
© 2025 Manfred Baumeister

JavaScript Application: Display Web-safe Colors - English Version JavaScript-Anwendung: Websichere Farben anzeigen - Deutsche Version