Sunday, 5 June 2011

Printing out HTML/CSS Colours

I was trawling around websites trying to get an idea for colour schemes. They all appear to be infested with banner ads and anti-virus peddlers.

For people who like to roll their own, here is a Python script to dump out the hex codes for the first 16**3 colours:


#Script to dump out all basic web colours in a table



print """






print '<tr>'

for alpha1 in hex_colours:

for alpha2 in hex_colours:


for alpha3 in hex_colours:


print '<td style=\"background-color:#%s ;\">%s</td>' % (alpha123,alpha123)

#Every 20 cells, we want to change row

if counter%20==0 :

print '</tr>\n<tr>'

counter += 1

print '</tr>'

print """




And here is the output file: Web colours

Original Python script - Blogger mangled mine

No comments: