The rgb() function specifies a color by its red, green, and blue intensities as integers from 0 to 255 or as percentages. It maps directly to how screens produce light by combining red, green, and blue sub-pixels.
RGBA and Transparency
The rgba() function adds an alpha channel as a fourth argument — a number from 0 (fully transparent) to 1 (fully opaque). Fractional values produce partial transparency: rgba(0, 0, 0, 0.5) is 50% transparent black. This is commonly used for overlays, shadows, and frosted-glass effects. Modern CSS also allows the new rgb(r g b / a) space-separated syntax, which accepts the same range of values.
Use rgba() for overlays rather than setting opacity on the element — the opacity property applies to the whole element including its children, while rgba() only affects the background, leaving text and child elements at full opacity.