Using an alpha value to update a color's transparency will change the hex code format from #RRGGBB to #RRGGBBAA (where alpha is A ). The first six values (the red, green, and blue ones) remain the same. The AA value in #RRGGBBAA can range from the lowest value possible ( 00 ) to the highest value possible ( FF ).
You can actually apply a hex code color that is transparent. The hex code for transparent white (not that the color matters when it is fully transparent) is two zeros followed by white's hex code of FFFFFF or 00FFFFFF.
RGBA Colors RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity for a color. An RGBA color value is specified with: rgba(red, green, blue, alpha). The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).
A hex color code is a 6-symbol code made of up to three 2-symbol elements. Each of the 2-symbol elements expresses a color value from 0 to 255. The code is written using a formula that turns each value into a unique 2-digit alphanumeric code. For example, the RGB code (224, 105, 16) is E06910 in hexadecimal code.
It looks like there is no hex alpha format: http://www.w3.org/TR/css3-color/
Anyway, if you use a CSS preprocessor like SASS then you can pass an hex to rgba
:
background:
rgba(#000, 0.5);
And the preprocessor just converts the hex code to rgb automatically.
In CSS 3, to quote from the spec, "there is no hexadecimal notation for an RGBA value" (see CSS Level 3 spec). Instead you can the use rgba() functional notation with decimals or percentages, e.g. rgba(255, 0, 0, 0.5) would be 50% transparent red. RGB channels are 0-255 or 0%-100%, alpha is 0-1.
In CSS 4*, you can specify the alpha channel using the 7th and 8th characters of an 8 digit hex colour, or 4th character of a 4 digit hex colour (see CSS Level 4 spec*)
As of July 2021, >93% of users can be expected to understand the #RGBA format
It has been supported since:
It is not supported in:
Up to date browser support information is available on CanIUse.com
*Technically still in draft, but given the browser support this is unlikely to be changed.
I'm not sure if there is an official standard-
RGBA is the representation I've seen for Web Macromedia and others use ARGB
I believe that RGBA is the more common representation.
If it helps this is from W3 for CSS3
http://www.w3.org/TR/css3-color/#rgba-color
EDIT (Patrick): quote from the above W3 link
Unlike RGB values, there is no hexadecimal notation for an RGBA value
Chrome 52+ supports alpha hex:
background: #56ff0077;
For older browsers, you'll have to use:
background-color: rgba(255, 220, 0, 0.3);
You could try putting the hex color into the color picker of GIMP or photo shop to get the RGB value and then using the alpha value. eg. red is #FF0000
or rgb(255,0,0
) if you want red with an alpha value of .5 then rgba(255,0,0,.5)
.
Maybe not exactly what you wanted but hopefully helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With