Jens Oliver Meiert

The Truth About !important

Post from March 10, 2015 (↻ March 30, 2016), reflecting Jens the .

This and many other posts are also available as a pretty, well-behaved e-book: On Web Development.

This was on my mind for the last eight thousand years, and I needed a quick cheeky cushion post between my latest (tech) book and upcoming closure of my one and a half years of traveling around the world. What are we waiting for.

Sometimes I wake up at night, full of agony, tears in my eyes. The Holiest Alliance Against !important is haunting me. I see their countless crusaders gallop at innocent web developers with merciless force, incessantly blowing their deafening horns to never ever ever ever use !important, ever; !important, code of the wicked.

I wake up because, nonsense.

!important is not !important.

Nonsense, because !important is an—important part of the cascade. !important is so important, it even has its own section in the spec:

CSS attempts to create a balance of power between author and user style sheets. By default, rules in an author’s style sheet override those in a user’s style sheet […].

However, for balance, an “!important” declaration (the delimiter token “!” and keyword “important” follow the declaration) takes precedence over a normal declaration. Both author and user style sheets may contain “!important” declarations, and user “!important” rules override author “!important” rules. This CSS feature improves accessibility of documents by giving users with special requirements (large fonts, color combinations, etc.) control over presentation.

!important, a legitimate feature of CSS, is a tool. It’s a critical tool for users, for who it’s what guarantees that their rules (when they ever put any in place) get applied. And it’s an important tool for authors, us web developers, not just to test (admit, 99% here have used !important for debugging purposes) but also to come up with sometimes incredibly elegant solutions.

To ban !important, as my nightmare-widened eyes see much too many times, resembles dogmatic over-simplification. To ban !important doesn’t, by definition, show understanding of what it’s doing and what it’s there for, and with that often looks like convenience, not to be bothered to explain when !important should best be used.

I won’t explain the intricacies of !important, either. Not here. My favorite Harry, for example, does a nice job doing so already, sharing some of the issues, and what we can do instead. I normally buy myself time by advising not to use !important too liberally, and all the time. But the point of this post is simply to, once and for all, establish that:

!important is legitimate. It’s useful. It’s not going to go away. And so instead of screaming “no !important,” we should relax, and use (and teach to use) !important responsibly.

About the Author

Jens Oliver Meiert, photo of July 27, 2015.

Jens Oliver Meiert is a German philosopher and developer (Google, W3C, O’Reilly). He experiments with arts and adventure. Here on meiert.com he shares and generalizes and exaggerates some of his thoughts and experiences.

There’s more Jens in the archives and at Amazon. If you have any questions or concerns (or recommendations) about what he writes, leave a comment or a message.

Read More

Have a look at the most popular posts, possibly including:

Or maybe say hi on Google+, Twitter, or LinkedIn?

Looking for a way to comment? Comments have been disabled, unfortunately.

Found a mistake? Reward! Email me, jens@meiert.com.

You are here: HomeArchive2015 → The Truth About !important

Last update: March 30, 2016.

“Government, in the long run, is usually no better than the people governed.”