How do I add opacity to a hex color?
Add two alpha digits to the end of a six-digit hex code, or convert the hex to rgba() and set the fourth value from 0 to 1. For example #2563eb at 50% opacity is #2563eb80 or rgba(37, 99, 235, 0.5).
To convert HEX to RGBA, turn each pair of hex digits into a 0–255 number and add an alpha from 0 to 1: #2563eb at 50% opacity is rgba(37, 99, 235, 0.5).
rgba(37, 99, 235, 0.5)#2563EB80background-color: rgba(37, 99, 235, 0.5);#2563eb that is 25, 63 and eb.25 → 37, 63 → 99, eb → 235.rgba(37, 99, 235, 0.5), or the 8-digit hex #2563eb80.Need the plain channels first? Use the HEX to RGB converter, then come back here for the alpha. Going the other way? The RGB to HEX converter turns rgba() back into a hex code, and the color format converters cover every other pair. Need the solid colour a transparent rgba() makes? Use the RGBA to HEX converter.
| Opacity % | Alpha (0–1) | Hex suffix | Example |
|---|---|---|---|
| 100% | 1 | FF | #2563ebFF |
| 95% | 0.95 | F2 | #2563ebF2 |
| 90% | 0.90 | E6 | #2563ebE6 |
| 85% | 0.85 | D9 | #2563ebD9 |
| 80% | 0.80 | CC | #2563ebCC |
| 75% | 0.75 | BF | #2563ebBF |
| 70% | 0.70 | B3 | #2563ebB3 |
| 65% | 0.65 | A6 | #2563ebA6 |
| 60% | 0.60 | 99 | #2563eb99 |
| 55% | 0.55 | 8C | #2563eb8C |
| 50% | 0.50 | 80 | #2563eb80 |
| 45% | 0.45 | 73 | #2563eb73 |
| 40% | 0.40 | 66 | #2563eb66 |
| 35% | 0.35 | 59 | #2563eb59 |
| 30% | 0.30 | 4D | #2563eb4D |
| 25% | 0.25 | 40 | #2563eb40 |
| 20% | 0.20 | 33 | #2563eb33 |
| 15% | 0.15 | 26 | #2563eb26 |
| 10% | 0.10 | 1A | #2563eb1A |
| 5% | 0.05 | 0D | #2563eb0D |
| 0% | 0.00 | 00 | #2563eb00 |
Add two alpha digits to the end of a six-digit hex code, or convert the hex to rgba() and set the fourth value from 0 to 1. For example #2563eb at 50% opacity is #2563eb80 or rgba(37, 99, 235, 0.5).
80. Half of 255 is 127.5, which rounds to 128, and 128 in hexadecimal is 80. So 50% opacity appends 80 to a six-digit hex, giving #2563eb80 for that blue.
Both work in every modern browser. Use rgba() when you want the alpha as a readable decimal, and 8-digit hex when you want one compact token for a design system or a CSS variable. The rendered color is the same.
No. Alpha inside rgba() only fades that one color, so text and child elements keep their own opacity. The separate opacity property fades the whole element, children included, which is why rgba() is safer for overlays.