What is the difference between rgb() and rgba()? What does the alpha channel do?
rgb() sets a color through three components: red, green, and blue. Example:
css
color: rgb(255, 0, 0);rgba() adds a fourth parameter, the alpha channel, which controls transparency:
css
color: rgba(255, 0, 0, 0.5);The alpha channel accepts a value from 0 to 1:
1, a fully opaque color0, fully transparent0.5, semi-transparent
The difference: rgb(), without transparency, rgba(), with the ability to specify it.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.