Filed in Programming, Work
With 23 Comments
Web Safe Color Palette/Chart Using PHP

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.
- Wikipedia web colors
- Immigration-USA Html Color Chart
- Lynda Web palette
- Perpectual Pc’s Web Safe Color
- Web Monkey Color Charts
- Html Color Codes











23 Comments so far
:super_man: coba dulu ah
nice idea … coba ah :girl:
Woke… keren…. :exciting:
Bisa dicoba nih….. :red_heart:
sip bang … sangat-sangat berguna nih … terima kasih dah berbagi ya
makasih codenya gan…:-)
@all : You’re welcome. :girl:
:exciting: hahahA… cool idea gand !
thx so much for sharing ….. ?????
nice bang…
sayang belon install xampp… :grimace:
ouw … bisa gt yak :scorn: :scorn:
mash mikir codenya :shame: :shame:
Hey, nice post, really well written. You should write more about this. I’ll definitely be subscribing.
Makasih infonya…
wah menarik ini. bisa jadi bahan bikin framework tuh kalau diterusin.
Izin Copas dulu ah..
Makasih ya .. :victory:
aku sering eror pake xampp…hiks
Ga usah pke AXMPP, filenya lngsung d taro d selfhosting bisa gak yah gands ? Hehehe
Coba dulu ach
Tinggal kopi paste nich
kalau saya buka color pallete di photoshop kang… hehehe.. trsu diapalin kodenya…
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:
Huhuhuhhu… coba2 dolo :victory:
@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:
Bang, link yg merujuk ke XAMPP itu ga valid, silahkan dicek deh..
BTW thanks for the practice :big_smile: