Browsers discard a declaration whose value its property does not accept, so the intended style never applies and the element keeps the value from an earlier declaration, or its inherited or initial value. This rule raises an issue on the first part of a value that the property’s CSS grammar rejects, such as a misspelled or borrowed keyword, a quoted keyword, or a number where a length is required. Replace that part with a value the property accepts.
This rule applies only to plain CSS. It does not raise issues in SCSS, Sass, or Less files.
Replace the misspelled keyword and the keyword that the property does not accept:
.card {
position: absolut; /* Noncompliant: misspelled keyword */
border-radius: none; /* Noncompliant: "none" is not a "border-radius" value */
}
.card {
position: absolute;
border-radius: 0;
}
Other values that a property does not accept include a quoted keyword, a space inside a dimension, and a keyword copied from another property:
.card {
transition: opacity 0.1 s; /* Noncompliant: space inside the dimension */
display: 'inline'; /* Noncompliant: quoted keyword */
top: red; /* Noncompliant: "red" is not a valid "top" value */
}
.card {
transition: opacity 0.1s;
display: inline;
top: 0;
}
A math expression cannot add or subtract a number and a length or percentage:
.card {
width: calc(100% + 10); /* Noncompliant: cannot add a number to a percentage */
}
.card {
width: calc(100% + 10px);
}
A custom property registered with @property in the same file must receive a value matching its declared syntax.
Otherwise, it falls back to its inherited or initial value. Change the value, or change the syntax descriptor if the value is the
intended one:
@property --gap {
syntax: "<length>";
inherits: false;
initial-value: 0px;
}
.card {
--gap: red; /* Noncompliant: "--gap" only accepts lengths */
}
@property --gap {
syntax: "<length>";
inherits: false;
initial-value: 0px;
}
.card {
--gap: 1rem;
}
Some parts of a value are checked by related rules instead:
#fff, which {rule:css:S4647} checks for invalid hex digits10px, which {rule:css:S4653} checks for unknown unitslinear-gradient(), which {rule:css:S4651} checks as the gradient direction@font-face, which {rule:css:S8775} checksA valid hex color or a number with a known unit is not checked against the property, so top: 10deg does not raise an issue.
Only the first part of a value that the property does not accept is reported. When that part is not checked by this rule, the declaration does not raise an issue, but it can once the related rule’s issue is fixed.
This rule does not raise an issue for deliberate compatibility patterns and for values that it cannot check reliably:
filter values such as alpha(opacity=50) or FlipH\9, \0, or \0/-webkit-perspective, which WebKit reads as pixelstheme()var(), env(), attr(), if(), or calc-size(), and the
arguments of min(), max(), and clamp(), except for invalid math expressions@property rule in the same file, or whose syntax is "*"inherit, which every custom property acceptsNone of the following declarations raise an issue:
.legacy {
display: -ms-flexbox;
filter: alpha(opacity=50);
margin-top: 1px \9;
-webkit-perspective: 1000;
color: theme('colors.gray.400');
margin: var(--spacing);
--anything: red;
}