COLORS IN CSS

css3

Colors are specified using predefined color names or RGB, HEX, HSL, RGBA, HSLA values.

NAMES OF THE CSS COLORS

In CSS, a color can be specified using a predefined color name. CSS/HTML supports 140 standard color names.

Color names

Another valuable resource where you can find and choose from thousands of colors is the following website: https://coolors.co/ select explore and then the desired palette.

CSS BACKGROUND COLOR

Set the background color for HTML elements.

CSS TEXT COLOR

Set the text color.

CSS BORDER COLOR

Set the border color.

VALUES OF THE CSS COLORS

In CSS, colors can also be specified using RGB values, HEX values, HSL values, RGBA values, and HSLA values.

RGB COLORS

An RGB color value represents RED, GREEN, and BLUE light sources. In CSS, a color can be specified as an RGB value, using this formula:

rgb (red, green, blue)

Each parameter (red, green and blue) defines the color intensity between 0 and 255. For example, rgb (255, 0, 0) is displayed as red, because red is set to the highest value (255) and the others are set to 0. To display black, set all color parameters to 0, like this: rgb (0, 0, 0). To display white, set all color parameters to 255, like this: rgb (255, 255, 255).

RGBA VALUES

RGBA color values ​​are an extension of RGB color values ​​with an alpha channel, which specifies the opacity of a color. An RGBA color value is specified with:

rgba (red, green, blue, alpha)

The alpha parameter is a number between 0.0 (completely transparent) and 1.0 (no transparency).

RGBA

HEXADECIMAL COLORS

A hexadecimal color is specified with: #RRGGBB, where the hexadecimal integers RR (red), GG (green), and BB (blue) specify the color components. In CSS, a color can be specified using a hexadecimal value of the form:

#rrggbb

Where rr (red), dd (green) and bb (blue) are hexadecimal values ​​between 00 and ff (equal to the decimal 0-255). For example, #ff0000 is displayed as red, because red is set to the highest value (ff) and the others are set to the lowest value (00). To display black, set all values ​​to 00, like this: #000000. To display white, set all values ​​to ff, like this: #ffffff.

USE THREE DIGITS TO EXPRESS A HEXADECIMAL VALUE

Sometimes you will see a three-digit hexadecimal code in the CSS source code. The 3-digit hexadecimal code is a shortcut for some 6-digit hexadecimal codes. It has the following form:

#rgb

Where r, g and b represent the red, green and blue components with values ​​between 0 and f. The three-digit hexadecimal code can only be used when both values ​​(RR, GG and BB) are the same for each component. So, if we have #ff00cc, it can be written like this: #f0c.

HSL COLORS

HSL stands for hue, saturation and lightness. In CSS, a color can be specified using hue, saturation, and lightness (HSL) in the form:

hsl (hue, saturation, brightness)

Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue. Saturation is a percentage value, 0% indicates a shade of gray and 100% is the full color. Brightness is also a percentage, 0% is black, 50% is neither light nor dark, 100% is white

SATURATION

Saturation can be described as the intensity of a color. 100% is pure color, no shade of gray 50%: 50% gray, but you can still see the color. 0% is completely gray, the color is no longer visible.

Saturation

BRIGHTNESS

The brightness of a color can be described as how much light you want to give to the color, where 0% means no light (black), 50% means 50% light (neither dark nor light) 100% means full brightness (white).

lightness

HSLA VALUES

HSLA color values are an extension of HSL color values with an alpha channel, which specifies the opacity of a color. An HSLA color value is specified with:

hsla (hue, saturation, brightness, alpha)

The alpha parameter is a number between 0.0 (completely transparent) and 1.0 (no transparency):

Copy to Clipboard
Copy to Clipboard
Copy to Clipboard

LINKS TO PREVIOUS POST

PREVIOUS POST LINKS

LINK TO THE CODE ON GITHUB

GITHUB