#CSS Colors
Ways to define colors in CSS:
- Color name, e.g.,
red,pink,green, etc. #RGBA—R,G, andBare red, green, and blue channels;Ais the alpha (opacity) channel. Each is a single hexadecimal digit (0–f, case-insensitive).#RRGGBBAA— Each channel takes two hex digits.#RGB— A shorthand for#RRGGBB, without alpha.#RRGGBB— Full hex format, without alpha.rgb(R, G, B)— Each channel takes a value from0to255.rgba(R, G, B, A)— Adds the alpha channel as a decimal from0(transparent) to1(opaque).
The alpha channel is used in blending when colors overlap. It typically controls the element's opacity.
#color
The color property sets the text color. For example:
<p style="color:pink;">Primers — Your programming companion</p>
<p style="color:#39c5bb;">Primers — Your programming companion</p>
<p style="color:rgb(102, 204, 255);">Primers — Your programming companion</p>
HTML
#background-color
The background-color property sets the background color of an element. For example:
<p style="background-color:pink;">Primers — Your programming companion</p>
<p style="background-color:#39c5bb;">Primers — Your programming companion</p>
<p style="background-color:rgb(102, 204, 255);">Primers — Your programming companion</p>
HTML
#Standard Color Names
HTML/CSS Standard Color Names