Media queries and @media rules do not affect !important behavior in any way, because they do not have any effect on any part of the cascade , (In addition, this means you cannot use the @media to βremoveβ the !important flag , even if you use a more specific selector.)
When your media query matches, the browser sees this:
a{ color:#0000FF!important; } a{ color:#FF0000; }
And when it is not, he sees this:
a{ color:#0000FF!important; }
Both cases lead to the fact that the first set of rules takes precedence, but does not prevent, for example, the declaration of !important with a more specific selector or built-in !important style from overriding.
Here is another example that illustrates this better:
a{ color:#0000FF!important; } @media (max-width: 300px){ a:link,a:visited{ color:#FF0000!important; } }
When a media request is matched, the browser sees this:
a{ color:#0000FF!important; } a:link,a:visited{ color:#FF0000!important; }
This leads to the fact that the second rule takes precedence, since it has a more specific selector (for at least a elements that correspond to the pseudo-class ). If this does not match the media query, then only the first rule will have any effect, as indicated above.