Loading...

CSS Color Functions

CSS FunctionsCSS Multiple Backgrounds

CSS provides the ability to use various color functions that allow us to more precisely control the display, transparency, and combination of colors. With RGBA, HSL, and modern color-mix functions, we can flexibly shape the color scheme of websites.

RGBA function

RGBA includes a red, green, and blue component along with an alpha value that controls transparency. The value can range between 0 and 1, where 0 means fully transparent and 1 means fully opaque.

This example demonstrates a semi-transparent red background color using RGBA.

HSL function

HSL (Hue, Saturation, Lightness) is another color model that makes it easier to adjust brightness or saturation. Hue is defined in degrees (0–360), while Saturation and Lightness are expressed in percentages.

In this example, a bluish shade is displayed using the HSL color model.

color-mix function

The color-mix function is a modern CSS function that allows combining two or more colors in given ratios. This can be useful for creating shades or building dynamic color schemes.

This example creates a blended shade by combining red and blue colors using the color-mix function.

Tips for using color functions

Color functions allow much more flexible color handling, but they should be used thoughtfully to ensure design consistency.

  • RGBA is particularly useful for overlay effects or semi-transparent layers.
  • HSL makes it easier to adjust color tones, for example for hover states.
  • Color-mix offers new possibilities for building dynamic color schemes, but always check browser support.

✨ Ask Lara

Please sign in to ask Lara about CSS color functions.

Track Your Progress 🚀

Learn more easily by tracking your progress completely for free.


Top tools

CodeHubBoardly NEWLinksy NEWChromo NEW

Select Language

Set theme

© 2025 ReadyTools. All rights reserved.