colorsstandardsw3c

Hex representation of a color with alpha channel?


Is there a W3 or any other noteworthy standard on how to represent a color (including alpha channel) in hex format?

Is it #RGBA or #ARGB?


Solution

  • 2025 answer:

    Yes, in CSS use #RGBA or #RRGGBBAA.

    2015 answer:

    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 Color Level 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 Color Module Level 4 spec*)

    As of Feb 2025, >96% 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