Web Safe Color Palette/Chart Using PHP

Example of web safe color palette screenshots

This is just a simple idea that was headed off in My mind. When building a website, we often confronted with color selection issue. What color do we need to set up in our web/blog? This color is a safe one? What color is match with this color? And much more question might be flying in our mind. So, I intended to share a php code to do this automatically.

Using web safe color pallette, you can save your time. Rather than opening other website that also provide web save color, you just open this php code using your favourite web browser and access it locally. But, this code require you to have a Web Server and a PHP installed in your computer. I suggest you to using XAMPP if you don’t have yet.

Here is the code.

<html>
	<head>
		<title>Web Safe Colour Chart</title>
		<style>
			td
			{
				font-family:verdana; font-size:0.6em;
				padding:5px; width:100px;
			}
		</style>
	</head>
	<body>
<?php
	$r = 0;
	$g = 0;
	$b = 0;
	$hexCode = array(0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f');
 
	echo "<table>";
 
	for($b=0;$b<=15;$b+=3)
	{
		for($g=0;$g<=15;$g+=3)
		{
			echo "<tr>";
			for($r=0;$r<=15;$r+=3)
			{
				echo "<td style='background: #".convertToRgbColor($hexCode[$r], $hexCode[$g], $hexCode[$b]).";'>".convertToRgbColor($hexCode[$r], $hexCode[$g], $hexCode[$b])." </td>";
			}
			echo "</tr>";
		}
	}
	echo "</table>";
 
	function convertToRgbColor($r,$g,$b)
	{
		return $r.$r.$g.$g.$b.$b;
	}
?>
	</body>
</html>

You just save the code with your_defined_file_name.php and run it from your browser. Lets play color!!

Other online web color pallette.

  • Digg
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Reddit
  • StumbleUpon
  • Technorati
  • Design Float
  • Furl
  • LinkedIn

Possibly Related Post(s)

Tags : , , , , , , , , ,

23 Comments so far

  • :super_man: coba dulu ah

    at 11 June 2009, 19:02 PM
  • nice idea … coba ah :girl:

    at 11 June 2009, 20:56 PM
  • Woke… keren…. :exciting:

    at 11 June 2009, 22:22 PM
  • Bisa dicoba nih….. :red_heart:

    at 11 June 2009, 22:24 PM
  • sip bang … sangat-sangat berguna nih … terima kasih dah berbagi ya :)

    at 12 June 2009, 1:58 AM
  • makasih codenya gan…:-)

    at 12 June 2009, 6:56 AM
  • @all : You’re welcome. :girl:

    at 12 June 2009, 10:26 AM
  • :exciting: hahahA… cool idea gand !
    thx so much for sharing ….. ?????

    at 12 June 2009, 13:05 PM
  • nice bang…

    sayang belon install xampp… :grimace:

    at 12 June 2009, 16:34 PM
  • ouw … bisa gt yak :scorn: :scorn:
    mash mikir codenya :shame: :shame:

    at 12 June 2009, 19:23 PM
  • Hey, nice post, really well written. You should write more about this. I’ll definitely be subscribing.

    at 13 June 2009, 6:10 AM
  • Makasih infonya…

    at 13 June 2009, 7:00 AM
  • wah menarik ini. bisa jadi bahan bikin framework tuh kalau diterusin.

    at 13 June 2009, 8:54 AM
  • Izin Copas dulu ah..
    Makasih ya .. :victory:

    at 13 June 2009, 13:50 PM
  • aku sering eror pake xampp…hiks

    at 14 June 2009, 8:04 AM
  • Ga usah pke AXMPP, filenya lngsung d taro d selfhosting bisa gak yah gands ? Hehehe

    at 14 June 2009, 10:37 AM
  • Coba dulu ach

    at 15 June 2009, 11:23 AM
  • Tinggal kopi paste nich

    at 15 June 2009, 11:24 AM
  • kalau saya buka color pallete di photoshop kang… hehehe.. trsu diapalin kodenya…

    at 15 June 2009, 16:05 PM
  • Hallo.. mas.. maaf ya baru mampir, seminggu blog sedang dalam masalah jadi bolak2 kudu kontak2an sama pihak hosting..

    Hmmm ternyata codingnya lumayan sederhana.. kirain manual mas.. 1-1 .. ternyata seperti ini :victory: :victory:

    at 15 June 2009, 21:54 PM
  • Huhuhuhhu… coba2 dolo :victory:

    at 16 June 2009, 6:24 AM
  • @Danta:
    1-1? Maksudnya?

    @ndop:
    Cepek deh… :exciting:

    @Aspirasiputih:
    Bisa juga.

    @rizoa:
    Install ulang aja.. :grimace:

    @uwiuw:
    bisa sih. Tapi rada malas klo sendiri. :big_smile:

    at 16 June 2009, 15:14 PM
  • Bang, link yg merujuk ke XAMPP itu ga valid, silahkan dicek deh..
    BTW thanks for the practice :big_smile:

    at 18 June 2009, 10:33 AM

feel free to leave a comment

About The Author

I am Ganda Manurung, a tweenty of something Web Addicted Developer. I currently live on Bogor, West Java. You can contact me at my[firstname].[lastname]@gmail.com.

Recent POST

XHTML VALID

Subscription