Skip to content

media-feature-name-value-no-unknown

Disallow unknown values for media features.

@media (color: red) {}
/** ↑ ↑
* feature and value pairs like these */

Use this rule to avoid values unknown to their media feature. Browsers evaluate the query to unknown, so its block never applies.

This rule considers values for media features defined within the CSS specifications to be known.

If duplicate problems are reported, you can turn off the corresponding rule.

This rule supports 2 message arguments: the media feature name and the unknown value.

{
"media-feature-name-value-no-unknown": true
}

The following patterns are considered problems:

@media (color: red) { top: 1px; }
@media (width: 10) { top: 1px; }
@media (width: auto) { top: 1px; }

The following patterns are not considered problems:

@media (color: 8) { top: 1px; }
@media (width: 10px) { top: 1px; }
{
"ignoreMediaFeatureNameValues": {
"media-feature-name": ["array", "of", "values", "/regex/"]
}
}

Ignore the specified media feature name and value pairs. You can specify a regex for a media feature name, such as { "/^color/": [] }.

Given:

{
"media-feature-name-value-no-unknown": [
true,
{
"ignoreMediaFeatureNameValues": {
"/^color/": ["--foo", "/^--bar/"]
}
}
]
}

The following patterns are not considered problems:

@media (color: --foo) {}
@media (color-gamut: --bar-baz) {}