CSS Tutorial

Colors

Key Concepts:

  • Color Names: Predefined color names, such as "red," "green," and "blue."
  • Hex Codes: Hexadecimal codes that represent colors, e.g., "#FF0000" for red.
  • RGB Values: Components of color (Red, Green, Blue), each ranging from 0 to 255.
  • HSL Values: Components of color (Hue, Saturation, Lightness), often used in web design.

Practical Steps:

Defining Colors for CSS:
  • Backgrounds: Use background-color property, e.g., background-color: #FF0000;.
  • Text: Use color property, e.g., color: #0000FF;.
  • Borders: Use border-color property, e.g., border-color: #00FF00;.

Example:

body {
  background-color: #F0F8FF;
  color: #333;
}

h1 {
  border: 5px solid #FF8C00;
}

Accessibility Tips:

  • Use high-contrast colors to ensure readability for people with low vision.
  • Avoid text colors that blend with the background.
  • Use color combinations that pass color contrast tests.