RGBA to HEX Color Conversion
RGBA (Red, Green, Blue, Alpha) and HEX are two ways to represent the same colors in CSS. RGBA uses decimal values (0-255 for each channel, 0-1 for alpha), while HEX uses hexadecimal notation (#RRGGBB or #RRGGBBAA).
When to Use HEX vs RGBA
- HEX (#3B82F6): Most common in CSS. Compact, widely supported. Best for solid colors without transparency.
- RGBA (rgba(59, 130, 246, 0.5)): Required when you need transparency. The alpha channel controls opacity (0 = fully transparent, 1 = fully opaque).
- HEX with alpha (#3B82F680): CSS supports 8-digit hex codes where the last 2 digits control alpha. 80 in hex = 128 in decimal = 50% opacity.
Conversion Formula
To convert RGBA to HEX: convert each R, G, B value (0-255) to a 2-digit hexadecimal number. For example, rgba(59, 130, 246, 1) becomes #3B82F6: 59→3B, 130→82, 246→F6.