You may use this way to convert the transparent for your current hex colour

For example, you want to set 40% alpha transparency to #000000 (black colour), you need to add 66 like this #00000066. The format is #RRGGBBAA so you could use a format like #00ff001C.

You could also check the full table hex -> transparent colour here https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4

Answer from Tony Tin Nguyen on Stack Overflow
๐ŸŒ
SimpleCSS
simplecss.eu โ€บ rgbatohex.html
RGBA to HEX Converter - Simple CSS Media Query Generator
When you want to make a color fully opaque, fully transparent or anywhere in between, you can choose to use RGBA or HEX. If you choose to use HEX then you will be changing the opacity property for an entire element, whereas if you use RGBA then you can set the opacity value for a single declaration.
People also ask

Why use RGBA instead of HEX for transparency?
HEX does not support transparency. RGBA includes an alpha channel, allowing precise adjustment of opacity levels.
๐ŸŒ
hexcalculator.org
hexcalculator.org โ€บ color-opacity
Hex Color Opacity Calculator
How is HEX converted to RGBA?
The first six digits of the HEX code are converted to their RGB decimal values (0-255). The Alpha value you select (from 0 to 1) is then added as the fourth component to create the final RGBA string.
๐ŸŒ
imgtocolor.com
imgtocolor.com โ€บ hex-to-rgba
HEX to RGBA Converter | Convert HEX Color to RGBA with Opacity
What is the difference between HEX and RGBA?
A standard HEX code (e.g., #FF0000) defines a color using Red, Green, and Blue values. RGBA does the same but adds a fourth value: 'A' for Alpha. This alpha channel controls the color's opacity, making it semi-transparent.
๐ŸŒ
imgtocolor.com
imgtocolor.com โ€บ hex-to-rgba
HEX to RGBA Converter | Convert HEX Color to RGBA with Opacity
๐ŸŒ
GitHub
gist.github.com โ€บ lopspower โ€บ 03fb1cc0ac9f32ef38f4
Hexadecimal color code for transparency ยท GitHub
function convertAlphaToHex(alp... = alphaHex.padStart(2, '0'); return paddedAlphaHex; } ... function applyAlphaToColorHex(hexColor, alpha) { var red = parseInt(hexColor.substring(1, 3), 16); var green = parseInt(he...
๐ŸŒ
Hexcalculator
hexcalculator.org โ€บ rgb-to-hex
RGB to Hex Converter
December 4, 2025 - Modern web design frequently incorporates transparency effects, making our RGBA to Hex Converter invaluable for projects requiring alpha channel integration. Similarly, the Hex to RGBA Converter enables opacity adjustments while maintaining color consistency.
๐ŸŒ
Devoth
hex2rgba.devoth.com
HEX 2 RGBA Color Calculator | by @Devoth
There are many great HEX to RGB color converters out there, but usually they give you result in three separate fields (R, G & B), which is annoying because 99% of times when I need an RGB value from HEX, I need to paste it to some CSS rule. So why copy/paste from three fields, when you can have it in one field - nicely baked for CSS inclusion. ... Added an input field for the opacity, for people who don't like to work with sliders.
๐ŸŒ
OpenReplay
openreplay.com โ€บ tools โ€บ hex-to-rgb
Hex to RGB Converter
Absolutely! Our tool supports HEX color codes with alpha channels, converting them to RGBA format with precise opacity values.
๐ŸŒ
Hexcalculator
hexcalculator.org โ€บ color-opacity
Hex Color Opacity Calculator
December 4, 2025 - The Hex Color Opacity Calculator is a fast and accurate tool that lets you adjust the opacity level of any HEX color. It instantly converts your HEX value into an RGBA format and also shows how the color looks when blended over a white backgroundโ€”making it perfect for UI/UX, web design, and ...
Find elsewhere
Top answer
1 of 16
184

The CSS Color Module Level 4 will probably support 4 and 8-digit hexadecimal RGBA notation!

Three weeks ago (18th of December 2014) the CSS Color Module Level 4 editor's draft was submitted to the CSS W3C Working Group. Though in a state which is heavily susceptible to change, the current version of the document implies that in the somewhat near future CSS will support both the 4 and 8-digit hexadecimal RGBA notation.

Note: the following quote has irrelevant chunks cut out and the source may have been heavily modified by the time you read this (as mentioned above, it's an editor's draft and not a finalised document).
If things have heavily changed, please leave a comment letting me know so I can update this answer!

ยง 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 digits 0-9 or letters a-f (the case of the letters doesnโ€™t matter - #00ff00 is identical to #00FF00).

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 00 represents a fully transparent color and ff represent a fully opaque color.

Example 3
In other words, #0000ffcc represents the same color as rgba(0, 0, 100%, 80%) (a slightly-transparent blue).

4 digits

This is a shorter variant of the 8-digit notation, "expanded" in the same way as the 3-digit notation is. The first digit, interpreted as a hexadecimal number, specifies the red channel of the color, where 0 represents the minimum value and f represents the maximum. The next three digits represent the green, blue, and alpha channels, respectively.

What does this mean for the future of CSS colours?

This means that assuming this isn't completely removed from the Level 4 document, we'll soon be able to define our RGBA colours (or HSLA colours, if you're one of those guys) in hexadecimal format in browsers which support the Color Module Level 4's syntax.

Example

elem {
    background: rgb(0, 0, 0);           /* RGB notation (no alpha). */
    background: #000;                   /* 3-digit hexadecimal notation (no alpha). */
    background: #000000;                /* 6-digit hexadecimal notation (no alpha). */
    background: rgba(0, 0, 0, 1.0);     /* RGBA notation. */

    /* The new 4 and 8-digit hexadecimal notation. */
    background: #0000;                  /* 4-digit hexadecimal notation. */
    background: #00000000;              /* 8-digit hexadecimal notation. */
}

When will I be able to use this in my client-facing products?

All jokes aside: it's currently only the start of 2015, so these will not be supported in any browser for quite some time yet - even if your product is only designed to work on the most up-to-date of browsers you'll probably not be seeing this in action in a production browser any time soon.

View current browser support for #RRGGBBAA color notation

However, that said, the way CSS works means that we can actually start using these today! If you really want to start using them right now, as long as you add a fall back any non-supporting browsers will simply ignore the new properties until they are deemed valid:

figure {
  margin: 0;
  padding: 4px;
  
  /* Fall back (...to browsers which don't support alpha transparency). */
  background: #FEFE7F;
  color: #3F3FFE;
  
  /* Current 'modern' browser support. */
  background: rgba(255, 255, 0, 0.5);
  color: rgba(0, 0, 255, 0.75);
  
  /* Fall... foward? */
  background: #ffff007F; /* Or, less accurately, #ff08 */
  color: #0000ffbe;      /* Or #00fc */
}
<figure>Hello, world!</figure>

As long as you're viewing this answer on a browser which supports the background and color properties in CSS, the <figure> element in result of the above snippet will look very similar to this:

Using the most recent version of Chrome on Windows (v39.0.2171) to inspect our <figure> element, we'll see the following:

The 6-digit hexadecimal fall back is overridden by the rgba() values, and our 8-digit hexadecimal values are ignored as they are currently deemed invalid by Chrome's CSS parser. As soon as our browser supports these 8-digit values, these will override the rgba() ones.

UPDATE 2018-07-04: Firefox, Chrome and Safari are support this notation now, Edge still missing but will probably follow (https://caniuse.com/#feat=css-rrggbbaa).

2 of 16
130

I found the answer after posting the enhancement to the question. Sorry!

MS Excel helped!

simply add the Hex prefix to the hex colour value to add an alpha that has the equivalent opacity as the % value.

(in rbga the percentage opacity is expressed as a decimal as mentioned above)

Opacity %   255 Step        2 digit HEX prefix
0%          0.00            00
5%          12.75           0C
10%         25.50           19
15%         38.25           26
20%         51.00           33
25%         63.75           3F
30%         76.50           4C
35%         89.25           59
40%         102.00          66
45%         114.75          72
50%         127.50          7F
55%         140.25          8C
60%         153.00          99
65%         165.75          A5
70%         178.50          B2
75%         191.25          BF
80%         204.00          CC
85%         216.75          D8
90%         229.50          E5
95%         242.25          F2
100%        255.00          FF
๐ŸŒ
ImgToColor
imgtocolor.com โ€บ hex-to-rgba
HEX to RGBA Converter | Convert HEX Color to RGBA with Opacity
Easily convert any HEX color to RGBA by adding an alpha (opacity) value.
๐ŸŒ
Kilian Valkhof
kilianvalkhof.com โ€บ home โ€บ css & html โ€บ css hexadecimal colors with transparency, a conversion tool
CSS hexadecimal colors with transparency, a conversion tool | Kilian Valkhof
October 29, 2016 - This notation works with both 8 digits and 4 digits (shorthand notation) so #ffffff88 and #fff8 both correspond to rgba(255,255,255,0.53); Quite a neat trick that works in Chrome from version 52 onwards (and Opera version 39, as they are both ...
๐ŸŒ
OpenReplay
openreplay.com โ€บ tools โ€บ rgba-to-hex
RGBA to HEX Converter
It's a more concise alternative to using rgba() notation. ... To convert from 8-digit hex to RGBA, split the hex into RGB components and convert the last two digits to a decimal between 0 and 1 for the alpha value.
๐ŸŒ
GitHub
gist.github.com โ€บ danieliser โ€บ b4b24c9f772066bcf0a6
Convert Hex Color to rgba with opacity ยท GitHub
const convertHexToRGBA = (hex, opacity) => { let tempHex = hex.replace('#', '') if (tempHex.length === 3) { tempHex += tempHex } const r = parseInt(tempHex.substring(0, 2), 16) const g = parseInt(tempHex.substring(2, 4), 16) const b = ...
๐ŸŒ
Osvaldas Valutis
osvaldas.info โ€บ opacify-hex-color-in-css
Opacify HEX Color In CSS by Osvaldas Valutis
January 18, 2025 - p { color: color-opacity(var(--green), 0.5); background-color: color-opacity(#1a8745, 0.1); border-color: color-opacity(rgb(26 135 69), 0.1); } Stylelint might have to say a few words about the new function, letโ€™s silence it:
๐ŸŒ
Rgbacolorpicker
rgbacolorpicker.com โ€บ rgba-to-hex
RGBA to Hex
Find 4/5/6/7/etc. Letter Words With Specific Letters ... Hex to RGBA is a free, easy-to-use color converter that converts colors from hexadecimal to RGB and vice versa.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ css-hex-code-colors-alpha-values
How To Use CSS Hex Code Colors with Alpha Values | DigitalOcean
April 12, 2021 - Learn how to use hex codes in CSS and change the transparency of the color by using an alpha value. An introduction to hexadecimal numbers is included, too.
๐ŸŒ
CSS Generator
cssgenerator.org โ€บ rgba-and-hex-color-generator.html
RGBA and Hex Color Converter: Hex to RGBA and RGBA to Hex
A RGBA and Hex Color CSS Generator tool to quickly generate RGBA and Hex Color CSS declarations.
๐ŸŒ
Code Beautify
codebeautify.org โ€บ hex-to-rgba-converter
HEX to RGBA Converter to convert HEX Color to RGBA Color
A HEX to RGBA Converter takes the HEX code as input and returns the corresponding RGBA code, allowing designers and developers to easily switch between these two color representation formats. Transparency Control: The RGBA format contains an alpha channel representing a color's level of transparency or opacity. This feature is handy for designing elements with varying levels of transparency, such as overlays, shadows, and gradients.
๐ŸŒ
Chris Coyier
chriscoyier.net โ€บ 2023 โ€บ 05 โ€บ 12 โ€บ add-opacity-to-an-existing-color
Add Opacity to an Existing Color โ€“ Chris Coyier
May 12, 2023 - .add-opacity { /* original color */ background: #f06d06; background: rgb(from #f06d06 r g b / 50%); background: hsl(from #f06d06 h s l / 50%); background: oklch(from #f06d06 l c h / 50%); } Code language: CSS (css)