matt
matt

Reputation: 44303

Overwrite !important rule set within media-query? !unimportant?

Imagine this … 

@media screen and (min-width: 55.5em) {
    aside[role="attend"] {
        margin:0 !important;
    }
}

@media screen and (min-width: 61.5em) {
    aside[role="attend"] {
        margin:0; /* still !important but shouldn't be */
    }
}

Is there any way to overwrite or "remove" the !important declaration so it's not still applied within the higher min-width value?

Upvotes: 2

Views: 3393

Answers (1)

BoltClock
BoltClock

Reputation: 723719

No; the way the cascade works, there is no way to undo an !important declaration or make it "unimportant".

This is regardless of whether the rule occurs within different @media rules or anywhere else in a stylesheet. That means it's the same as though you didn't have the media queries there to begin with:

aside[role="attend"] {
    margin:0 !important;
}

aside[role="attend"] {
    margin:0;
}

Which, incidentally, is what a browser actually sees if both the min-width: 55.5em and min-width: 61.5em media queries are fulfilled.

You're much better off finding a way to remove that !important and using a more specific selector in your first @media rule instead.

Upvotes: 3

Related Questions