7
Today inspecting an element by Google Chrome I noticed that it has a very peculiar syntax for color, note that it is a RGB
, but still has a / 20%
which seems to me to function as a channel alpha transparency for color. Another detail is that there are no commas ,
separating the characters.
The "normal" would be
rgba(0, 0, 0, 0.2)
But they use
rgb(0 0 0 / 20%)
What is this pattern of writing color with transparency? Someone has more information, I found nothing about... Or this is a particular thing of the Chrome browser and how would the support of other browsers for this syntax?
div {
border: 1px solid #000;
width: 200px;
height: 70px;
padding: 5px;
}
.rgba {
background: rgba(255, 0, 0, 0.5);
}
.rgb {
background: rgb(255 0 0 / 50%);
}
<div class="rgba">BG: rgba(255, 0, 0, 0.5)</div>
<div class="rgb">BG: rgb(255 0 0 / 50%)</div>
W3C specification: https://drafts.csswg.org/css-color/#rgb-functions
– Woss
@Woss really fuck this documentation! From what I saw, and tested it too, I could write it all in
%
:D, likergb(100% 0% 0% / 50%);
haha. Another detail I saw is that rgb modernized, and "abolished" thea
, thenrgb(255, 0, 0, 0.5)
tb works normally... See: Also for legacy reasons, an rgba() Function also exists, with an identical Grammar and behavior to rgb().– hugocsl