Skip to content

noImportantStyles (CSS)

Language CSS
biome.json
{
"linter": {
"rules": {
"complexity": {
"noImportantStyles": "error"
}
}
}
}

Disallow !important declarations.

The CSS cascade normally chooses between conflicting declarations by considering factors such as cascade layers, selector specificity, and source order. !important raises a declaration’s priority and can make those conflicts harder to predict, override, and debug. Prefer adjusting the cascade, selectors, or declaration order.

.style {
color: red !important;
}
code-block.css:2:16 lint/complexity/noImportantStyles  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Avoid the use of the !important style.

1 │ .style {
> 2 │ color: red !important;
│ ^^^^^^^^^^
3 │ }
4 │

ℹ This style reverses the cascade logic, and precedence is reversed. This could lead to having styles with higher specificity being overridden by styles with lower specificity.

ℹ Unsafe fix: Remove the style.

2 │ ····color:·red·!important;
│ -----------
.style {
color: red;
}