« Fire Up FirefoxM2Crypto FTPS »

Tuesday, March 17th, 2009

HTML colors

Categories: Computers, Work

I know I could always just go to the Complete HTML True Color Chart which comes up when you feel lucky with the search term HTML Colors, but I was just playing with some loops in Python and made this short script.

html = open('colors.html','w')

html.write("<html><body><table style='width:100%;'>\n")

colors = ['00','33','66','99','cc','ff']

for r in colors:
	for g in colors:
		html.write("<tr>")
		for b in colors:
			html.write("<td style='background-color:#%s%s%s;'><span style='color:#%s%s%s;'>#%s%s%s</span></td>" % (r,g,b,r,g,b,r,g,b))
		html.write("</tr>")

html.write("</table></body></html>")
html.close()

If you put that in a text file called makecolors.py and then run it (assuming of course that you have python installed), you will get an html file with all the colors (browser safe). The reason I made the text the same color as the background is I specifically wanted to see the colors alone. Then I can just double click a cell and see what HTML color it is (or triple click if I want to get the '#' for easy copy and paste).

permalink 2:18pm by Brandon //comment 645 views

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)

©2010 by Brandon Contact design by brandonh

Credits: blog software | blog hosting | Francois

visits: stats