Alpha on a color and currentColor
color: #0B5853;
background: rgb(11 88 83 / 0.2);
border: 2px solid currentColor;A translucent background uses an alpha channel on that color. The border follows the text color through currentColor.
- No extra opacity is set here, so descendants would not be forced to fade with the element as a group.
<p class="swatch">Current color and a translucent background</p>
<style>
.swatch {
color: #0B5853;
background: rgb(11 88 83 / 0.2);
border: 2px solid currentColor;
padding: 0.5rem 0.75rem;
font-family: sans-serif;
}
</style>What this markup means
The text color is #0B5853. The background uses the same hue with 0.2 alpha, which paints only the background translucently. border-color is currentColor, so the border follows the text color without repeating the hex value. The page does not apply opacity on .swatch.
Related: Backgrounds, Borders