Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web-safe colour chart 1

Status
Not open for further replies.
Dec 8, 2003
17,047
GB
While looking back through some of my old code, I found this file, which displays a web-safe colour chart... I thought someone might find a use for it!

Dan

Code:
<HTML>
<HEAD>
<TITLE>Web-safe Colour Chart</TITLE>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
	var valRed, valGreen, valBlue, columnNum = 1;
	var strRed, strGreen, strBlue, colourString;

	function drawColourTable()
	{
		for (valBlue=0;valBlue<256;valBlue+=51)
			for (valGreen=0;valGreen<256;valGreen+=51)
				for (valRed=0;valRed<256;valRed+=51)
				{
					if (columnNum == 1) document.write('<TR>');
					strRed = '00'; strGreen = '00'; strBlue = '00';
					if (valRed > 0) strRed = valRed.toString(16).toUpperCase();
					if (valGreen > 0) strGreen = valGreen.toString(16).toUpperCase();
					if (valBlue > 0) strBlue = valBlue.toString(16).toUpperCase();
					colourString = '#' + strRed + strGreen + strBlue;
					document.write('<TD>'+ colourString +'</TD><TD WIDTH=&quot;30&quot; BGCOLOR=&quot;'+ colourString +'&quot;>&nbsp;</TD><TD WIDTH=&quot;40&quot;>&nbsp;</TD>');
					if (++columnNum == 7)
					{
						columnNum = 1;
						document.write('</TR>');
					}
				}
	}
//-->
</SCRIPT>
</HEAD>
<BODY STYLE=&quot;background-color:#000000;color:#FFFFFF;margin:10px;padding:0px;font-family:arial,helvetica,sans-serif&quot;>

<TABLE WIDTH=&quot;100%&quot; BORDER=&quot;0&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot;>
	<SCRIPT LANGUAGE=&quot;JavaScript&quot;>drawColourTable();</SCRIPT>
</TABLE>

</BODY>
</HTML>
 
Actually, I believe that all colors that have same pairs are safe web colors, i.e. #00AABB or #224477 or #AA5500. Can anyone confirm this?

Take Care,
Mike
 
Mike,

There are only 216 web-safe colours (i.e. 6x6x6).

Although with the high-colour graphics modes that most people have today, it's probably not as relevant to use web-safe colours anymore, but in the days of 256 colour modes, it was more important.

Having said all of that, IE 6 still displays some background colours differently to those same colours in an image, so maybe web-safe is still the way to go, who knows!

Dan
 
Thanks for clearing up that misunderstanding, Dan. :)

Take Care,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top