An invalid color definition will by default be interpreted as black, which is likely to have unintended impacts on the expected look and feel of
the website.
This rule raises an issue when a color definition (color
, background-color
) is not valid. The color definition is
considered valid when it is made of hexadecimal characters:
- longhand: 6 or 8 characters (when alpha is defined)
- shorthand variant: 3 or 4 characters (when alpha is defined)
Noncompliant code example
a {
color: #3c; /* Noncompliant; shorthand should be made of 3 characters */
}
div {
background-color: #3cb371a; /* Noncompliant; alpha should have 2 characters */
}
Compliant solution
a {
color: #3cc;
}
div {
background-color: #3cb371ac;
}