w1coding.comAll tutorials

CSS Colors

CSS lessons
  1. Environment Setup
  2. Introduction
  3. Tdisplay
  4. Basics
  5. Editors
  6. Syntax
  7. Colors
  8. Background
  9. Borders
  10. Margins
  11. Padding
  12. Width And Height
  13. Outline
  14. Texts
  15. Fonts
  16. Icons
  17. Links
  18. Lists
  19. Display
  20. Tables
  21. Max And With
  22. Positon
  23. Z Index
  24. Dropdown
  25. Overflow
  26. Float
  27. Navigation
  28. Image Sprites

CSS Colors Guide

CSS Color Formats

In CSS, colors can be specified in several formats. Below are some commonly used formats:

HEX Color

The HEX color code is a six-digit code representing the amount of red, green, and blue in a color. It is prefixed with a # symbol.

HEX Color Example: #3498db

RGB Color

RGB stands for Red, Green, and Blue. This format is written as rgb(red, green, blue), with each color value between 0 and 255.

RGB Color Example: rgb(46, 204, 113)

RGBA Color

RGBA is an extension of the RGB color model with an added alpha (opacity) value. The alpha value is between 0 (completely transparent) and 1 (completely opaque).

RGBA Color Example: rgba(241, 196, 15, 0.8)

HSL Color

HSL stands for Hue, Saturation, and Lightness. The hue is represented as an angle (0-360), saturation as a percentage, and lightness as a percentage.

HSL Color Example: hsl(344, 85%, 44%)

Choosing Colors for the Web

When selecting colors for a website, consider factors such as contrast, accessibility, and brand identity. Using colors with good contrast ensures readability, while considering accessibility helps all users experience your content effectively.

Experiment with different color schemes and formats to find the best combinations for your design needs.