CSS-Tricks
Follow
contrast-color()
The contrast-color() function takes a and returns either black or white, whichever is the most contrasting color for that value.
contrast-color() originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.