CSS font color

  • Purpose: This property sets the color of the text within an element.
  • Syntax: element { color: value; }
  • element: The HTML element you want to style (e.g., p, h1, span).
  • value: The color value. This can be:
    • A color name (e.g., red, blue, green)
    • An RGB value (e.g., rgb(255, 0, 0) for red)
    • An RGBA value (e.g., rgba(255, 0, 0, 0.5) for semi-transparent red)
    • A hexadecimal value (e.g., #FF0000 for red)
  • Example:
p {
color: blue;
}

This rule will make the text in all <p> elements blue.

CSS background color

  • Purpose: This property sets the background color of an element.
  • Syntax: element { background-color: value; }
  • element: The HTML element you want to style (e.g., p, h1, span).
  • value: The color value. This can be:
    • A color name (e.g., red, blue, green)
    • An RGB value (e.g., rgb(255, 0, 0) for red)
    • An RGBA value (e.g., rgba(255, 0, 0, 0.5) for semi-transparent red)
    • A hexadecimal value (e.g., #FF0000 for red)
  • Example:
body {
background-color: lightgray;
}

This rule will make the entire background of the webpage light gray.

Scroll to Top