A common subnet mask for a Class C IP address is 255.255.255.0. Each section of the subnet mask can contain a number from 0 to 255, just like an IP address. Therefore, in the example above, the first three sections are full, meaning the IP addresses of computers within the subnet mask must be identical in the first three sections.
Active2 years, 4 months ago
Should you use
rgba(0, 0, 0, 0)
or rgba(255, 255, 255, 0)
for transparency in CSS?What are the pros and cons of each?
BoltClock♦553k134134 gold badges12091209 silver badges12331233 bronze badges
JoeJoe11.4k99 gold badges4747 silver badges6767 bronze badges
3 Answers
The last parameter to the
rgba()
function is the 'alpha' or 'opacity' parameter. If you set it to 0
it will mean 'completely transparent', and the first three parameters (the red
, green
, and blue
channels) won't matter because you won't be able to see the color anyway.With that in mind, I would choose
rgba(0, 0, 0, 0)
because:- it's less typing,
- it keeps a few extra bytes out of your CSS file, and
- you will see an obvious problem if the alpha value changes to something undesirable.
You could avoid the
rgba
model altogether and use the transparent
keyword instead, which according to w3.org, is equivalent to 'transparent black' and should compute to rgba(0, 0, 0, 0)
. For example:This saves you yet another couple bytes while your intentions of using transparency are obvious (in case one is unfamiliar with RGBA).
As of CSS3, you can use the
CᴏʀʏCᴏʀʏtransparent
keyword for any CSS property that accepts a color.85k1717 gold badges145145 silver badges176176 bronze badges
There are two ways of storing a color with alpha. The first is exactly as you see it, with each component as-is. The second is to use pre-multiplied alpha, where the color values are multiplied by the alpha after converting it to the range 0.0-1.0; this is done to make compositing easier. Ordinarily you shouldn't notice or care which way is implemented by any particular engine, but there are corner cases where you might, for example if you tried to increase the opacity of the color. If you use
Mark RansomMark Ransomrgba(0, 0, 0, 0)
you are less likely to to see a difference between the two approaches.234k3131 gold badges303303 silver badges530530 bronze badges
There a small difference when u use rgba(255,255,255,a),background color becomes more and more lighter as the value of 'a' increase from 0.0 to 1.0. Where as when use rgba(0,0,0,a), the background color becomes more and more darker as the value of 'a' increases from 0.0 to 1.0.Having said that, its clear that both (255,255,255,0) and (0,0,0,0) make background transparent.(255,255,255,1) would make the background completely white where as (0,0,0,1) would make background completely black.
Rahul GoyalRahul Goyal