Each media feature accepts a specific kind of value. For example, hover accepts the keywords none and hover,
width accepts a length, and color accepts an integer. When a media feature receives a value it does not accept, browsers
treat that media query as not all, so it never matches. Unless another query in the same list matches, the styles inside the
@media block are skipped on every device, including the ones the author meant to target.
A wrong value is usually a keyword borrowed from another media feature, a misremembered keyword, or a number written without its unit. This rule raises an issue on each value that the media feature does not accept. Replace it with a value the media feature accepts.
This rule applies only to plain CSS, including <style> blocks in HTML files and Vue single-file components. It does not raise
issues in SCSS, Sass, or Less files, or in <style> blocks written in those languages.
Replace a keyword that the media feature does not accept:
@media (hover: pointer) { /* Noncompliant: "pointer" is not a "hover" value */
.menu:hover { color: blue; }
}
@media (orientation: horizontal) { /* Noncompliant: "horizontal" is not an "orientation" value */
.gallery { display: flex; }
}
@media (hover: hover) {
.menu:hover { color: blue; }
}
@media (orientation: landscape) {
.gallery { display: flex; }
}
Add the missing unit, or use a unit that matches the kind of value the media feature expects:
@media (min-width: 768) { /* Noncompliant: "min-width" requires a length */
.sidebar { display: block; }
}
@media (400px <= width <= 2s) { /* Noncompliant: "2s" is a time, not a length */
.card { padding: 1rem; }
}
@media (min-width: 768px) {
.sidebar { display: block; }
}
@media (400px <= width <= 800px) {
.card { padding: 1rem; }
}
This rule does not raise an issue for:
10pzx, which {rule:css:S4653} checksenv() or a math function such as calc(), whose result the rule does not check@import and @custom-media rules