CSS - Colors

CSS Colors

In this tutorial, I will be showing you all you need to know about colors and how you can use them in CSS

Color in CSS is a property that is used to set the color (foreground color) of any HTML element on your web page.

Types of Colors

Below are different types of colors.

NAMED COLORS

These are pre-defined colors as: blue, yellow, orange, green, black, white, etc.

RGB COLORS

RGB stands for (Red, Green, Blue) which takes value ranging from 0 - 256. Each value specifies the intensity of the color.

  • RGBA - This color is extension of the RGB color in which the A (Alpha) represents the opacity. Alpha value ranges from 0.0 to 1

HEX COLORS

HEX colors are hexadecimal color written in the format #RRGGBB which stands for # RR(Red) BB(Blue) GG(Green). Its value ranges between 00 and FF

  • 3-DIGIT HEX VALUE - This value is a shorthand (shortform) for some 6-digit hex color it follows the format #RGB, where r,g,b stands for red, green and blue; which takes value ranging between 0 to F
note
NOTE:

3-digit hex code are used only when both values (RR, GG, BB) are the same. For example: that is #FF00EE can be written as #f0e


HSL COLORS

HSL stands for Hue, Saturation, Light. Hue value ranges from 0 - 360. Saturation and Light ranges from 0 - 100%

tips
TIP:

Hue is the degree on the color wheel.
Saturation is the intensity of the color
Light is amount of light given to the color.


  • HSLA - This color is extension of the HSL color in which the A (Alpha) represents the opacity. Alpha value ranges from 0.0 to 1

KEYWORD COLORS

Keyword colors are like named colors which can also be used in CSS.

  • TRANSPARENT - This keyword is used to make the HTML element transparent.
  • CURRENTCOLOR - This keyword is used to refer to the current value of the element's color.
  • INHERIT - This keyword is used to make the element take the value of a property from its parent.

HWB COLORS

HWB stands for Hue, Whiteness, Blackness. Hue value ranges from 0 - 360. Whiteness and Blackness ranges from 0 - 100%

note
NOTE:

HWB is not supported in HTML yet!


CMYK COLORS

CMYK stands for Cyan, Magenta, Yellow and Black. It ranges from 0 - 100%

note
NOTE:

HWB is not supported in HTML yet!


Background Color

The background-color property in CSS is used to set the background color of any HTML element on your web page.

Caret Color

The caret-color property in CSS is used to set color for the text cursor (caret) inside an input or textarea form element.

Border Color

The border-color property in CSS is used to set the color of the border.

Others

Other color properties include:

  • box-Shadow
  • column-rule-color
  • outline-color
  • text-decoration-color
  • text-shadow
ADVERTISEMENTS

LEARNING IS A CONTINOUS PROCESS - PRACTICE MAKES PERFECT