Hex Colors: Numeric Representation for "Transparent"?
I Am Building a Web Cms in Which the User Can Choose Colours for Certain Site Elements. I Would Like to Convert All Colour Values to Hex to Avoid Any Further...
I am building a web CMS in which the user can choose colours for certain site elements. I would like to convert all colour values to hex to avoid any further formatting hassle ("rgb(x,y,z)" or named colours). I have found a good JS library for that.
The only thing that I can't get into hex is "transparent". I need this when explicitly declaring an element as transparent, which in my experience can be different from not defining any value at all.
Does anybody know whether this can be turned into some numeric form? Will I have to set up all processing instances to accept hex values or "transparent"? I can't think of any other way.
8 Answers
HEXA - #RRGGBBAA
There's a relatively new way of doing transparency, it's called HEXA (HEX + Alpha). It takes in 8 digits instead of 6. The last pair is Alpha. So the pattern of pairs is #RRGGBBAA. Having 4 digits also works: #RGBA
I am not sure about its browser support for now but, you can check the DRAFT Docs for more information.
§ 4.2. The RGB hexadecimal notations: #RRGGBB
The syntax of a
<hex-color>is a<hash-token>token whose value consists of 3, 4, 6, or 8 hexadecimal digits. In other words, a hex color is written as a hash character, "#", followed by some number of digits0-9or lettersa-f(the case of the letters doesn’t matter -#00ff00is identical to#00FF00).Must Read
8 digits
The first 6 digits are interpreted identically to the 6-digit notation. The last pair of digits, interpreted as a hexadecimal number, specifies the alpha channel of the color, where
00represents a fully transparent color andffrepresent a fully opaque color.Example 3
In other words,#0000ffccrepresents the same color asrgba(0, 0, 100%, 80%)(a slightly-transparent blue).