Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Custom Properties, Cascade and Global Keywords

The !important flag

Reference for the CSS !important flag: how it changes the cascade, how it interacts with layers and inline styles, and better alternatives, with live examples.

!important is a flag you add to the end of a declaration. It moves that declaration into a higher-priority group of the cascade, so it beats ordinary declarations no matter how specific their selectors are or where they appear.

Think of it as an emergency override, not a styling tool. Once two !important declarations compete, you are back to comparing specificity and order, and the only way out is yet another !important.

CSS
.hidden {
  display: none !important;
}

Try it

Important beats specificity

In A the selector #a.note is far more specific than p.plain, yet the important declaration wins. In C an inline style would normally beat any stylesheet rule, but not an important one.

Syntax

CSS
property: value !important;

Whitespace is allowed between the value and !, and the keyword is case-insensitive, but the usual style is a single space before !important.

Values

Syntax Description
!important Marks the declaration as important. It is not part of the value; it applies to the whole declaration.

Usage notes

  • Order of the cascade. Roughly, from weakest to strongest: normal user-agent, normal user, normal author, animations, then important author, important user, important user-agent, then transitions. So important declarations from the browser or user beat yours.
  • Reverse layer order. Among important declarations, earlier cascade layers win over later ones, the opposite of normal declarations. Important styles in an unlayered rule lose to important styles in layers.
  • Inline styles. Normal inline styles beat normal stylesheet rules, but a stylesheet !important beats a normal inline style. An inline !important beats both.
  • Animations ignore it. !important declarations inside @keyframes are ignored.
  • Common uses that are fine: utility classes (.hidden, .sr-only), overriding third-party inline styles you cannot edit, and user stylesheets for accessibility.
  • Common mistakes: fixing a specificity problem with !important, which makes the next override harder. Prefer lowering the other selector's specificity with :where(), cascade layers or reordering.
  • Debugging. Browser developer tools show !important declarations clearly; search for them first when a style will not change.

Browser support

Supported in every browser.