The CSS alpha() operate takes a relative shade and provides transparency to it.
.some-element {
background-color: alpha(from orange / 25%); /* 25% transparency */
}
Fairly simple, proper? Properly, there’s extra to it. For one, did you see that we’re working with a named shade in that final instance? Good, proper? Usually we must use a hex worth or some shade operate as an alternative to get that very same degree of transparency as a result of named colours can’t settle for alpha values.
One other factor, discover that we’re additionally working with the relative shade syntax in that instance. That’s a pleasant technique to make the idea of reworking colours constant throughout the board.
When would you want this? It’s a good query! Certain, it is smart when working with named colours, however we’re probably not supposed to make use of named colours, proper? They don’t all the time look the identical in each browser.
Colour variations
A greater use case is when you have got a design token for a shade that’s a strong worth, irrespective of the kind of shade worth.
:root {
--orange: rgb(255, 122, 24);
}
Keep away from new design tokens
And possibly you need to use that shade to make chilled out hyperlink underlines. You possibly can create a very new design token only for that occasion:
:root {
--orange: rgb(255, 122, 24);
--chill-orange: rgb(255, 122, 24 / 50%);
}
a {
text-decoration-color: var(--chill-orange);
}
…or you could possibly color-mix() it with clear:
:root {
--orange: rgb(255, 122, 24);
}
a {
text-decoration-color: color-mix(in srgb, var(--orange), 50%);
}
…or simply use the identical token and rework it on that occasion with some brevity:
:root {
--orange: rgb(255, 122, 24);
}
a {
text-decoration-color: alpha(from var(--chill-orange) / 50%);
}
Colour theming
Come to think about it, that’s fairly helpful for background-color too the place you want a lighter variation of a shade. I may see it getting used for shade theming gentle and darkish modes:
:root {
/* Help shade theming */
color-scheme: gentle darkish;
/* Orange is chill in gentle mode and strong in darkish mode */
--orange: light-dark(alpha(from rgb(255, 122, 24) / 50%), rgb(255, 122, 24));
}
Overriding a shade’s alpha
Let’s say you have got a design token that already has a little bit of alpha transparency on it:
:root {
--orange: rgb(255, 122, 24 / 25%);
}
The alpha() operate can override that when you may want further transparency with out altering the token in any respect:
:root {
--orange: rgb(255, 122, 24 / 25%); /* 25% clear */
}
a {
text-decoration-color: alpha(from var(--orange) / 50%); /* 50% clear */
}
Calculating alpha
We are able to additionally use alpha() with the calc() operate. It’s loads just like the final instance however we’re calculating the origin shade’s alpha fairly than setting it explicitly. That’s good for conditions the place you need your chill variation to be relative to the origin shade’s alpha fairly than fixing it to a particular worth:
:root {
--orange: rgb(255, 122, 24 / 10%); /* 10% clear */
}
a {
/* 75% extra clear than --orange's 10% */
text-decoration-color: alpha(from var(--orange) / calc(alpha * 75%));
}
Syntax
The official alpha() operate syntax seems like this:
= alpha( from / [ | none ] )
…the place could be a quantity or share. All of the examples we checked out earlier use percentages, however a quantity between 0 and 1 as a decimal works as effectively:
text-decoration-color: alpha(from var(--orange) / calc(alpha * .75)); /* 75% clear */
Specification
The alpha() operate is outlined in CSS Colour Module Degree 5 which is in Editor’s Draft on the time of writing. Which means the data can change between now and when it formally turns into a Candidate Suggestion.
Browser help
The CSS alpha() operate reached “Newly Obtainable” standing in September 2026 and is anticipated to be “Extensively Obtainable” in March 2029 on the time of writing.







