Performance: RGB and RGBA
This concept affects paint performance and visual rendering speed by controlling color transparency and compositing.
Jump into concepts and practice - no test required
background-color: rgba(0, 0, 0, 0.5); /* single semi-transparent background */
background-color: rgb(0, 0, 0); /* fallback opaque black */ background-color: rgba(0, 0, 0, 0.5); /* semi-transparent black */
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Solid RGB color | No extra DOM operations | 0 | Low paint cost | [OK] Good |
| Single RGBA background | No extra DOM operations | 0 | Moderate paint cost due to transparency | [OK] |
| Multiple stacked RGBA layers | No extra DOM operations | 0 | High paint cost due to compositing multiple layers | [X] Bad |
rgba(255, 0, 0, 0.5) color value represent in CSS?background-color: rgba(0, 128, 0, 0.3);
color: rgba(255, 255, 255, 2);
rgba() supports alpha transparency as the fourth parameter. rgb() does not.