Skip to main content

Creating HTML Colors

All Versions

To convert decimal color values to a hexadecimal representation, like the one used in HTML, try this line:

PS> '#{0:x2}{1:x2}{2:x2}{3:x2}' -f 255,202,81,0

PS> '#{0:x2}{1:x2}{2:x2}{3:x2}' -f 255,0,121,204

The first value sets the transparency, followed by the byte values for red, green, and blue.

Twitter This Tip! ReTweet this Tip!

Posted Nov 19 2014, 06:00 AM by ps1


I am the one