Skip to main content

HTML Guide

CSS: “background-color”: “X” is not a “background-color” value.

The background-color property in CSS expects a valid color value. Valid color values include keywords (such as red or blue), hexadecimal values (such as #FFFFFF), RGB values (such as rgb(255, 255, 255)), and others.

Example Fix

Invalid CSS

The following snippet is invalid because 0 is not a valid color value:

<style>
  .example {
    background-color: 0;
  }
</style>

Valid CSS

To fix it, use a valid color value. Below are examples using different types of color values:

Color Keyword
<style>
  .example {
    background-color: black;
  }
</style>
Hexadecimal Color
<style>
  .example {
    background-color: #000000;
  }
</style>
RGB Color
<style>
  .example {
    background-color: rgb(0, 0, 0);
  }
</style>
RGBA Color
<style>
  .example {
    background-color: rgba(0, 0, 0, 0.5);
  }
</style>

Learn more:

Related W3C validator issues