DEV Community

Discussion on: CSS Specificity and the use of !important: a case study

Collapse
 
malgosiastp profile image
Malgosia • Edited

I really like that you've emphasized that reading about specificity makes you review your own project and try to remove the !important quick fix solution from your project.

I'm now struggling with some legacy codebase where applying !important was the first idea to fix any problem, as investigating (especially because it involved third-party libraries with its own styles) was really time-consuming and quite hard.

And I'm wondering what is the best way to pass the knowledge and good practices about specificity to other developers in the team just to make them see the fastest solution is not the best because finally it could end up like this:

Ice Age cartoon fragment. Scrat trying to plug water leaks
Ice Age cartoon fragment. Scrat lose the fight with water leak

Keep up good work promoting learning about specificity instead of sticking to !important :)

PS: I think you've misspelled the resource of Mandy Michael. If wa talking about the same thing the project name is Batificity, and the link probably suppose to lead to batificity.com, not MDNsite :)

Collapse
 
munamohamed94 profile image
Muna Mohamed • Edited

Hi Malgosia, I'm glad you enjoyed the post! Thank you so much for sharing your experience, it really puts it into perspective the repercussions of using !important as a fix, particularly on legacy codebases where resolving the problems that arise with the overuse of !important can be tedious and very time-consuming.

I'm sorry to hear that you have the difficult task of correcting the mistakes of your predecessors and wish you the best of luck.

That is a perfect GIF to describe the impact that abusing !important can have on codebases! With regards to the best ways of passing knowledge and good practices to your team, I came across a really good post by

joefuzz image
, who had a similar struggle and the DEV community shared their experiences and gave some great tips and advice on solutions for this very problem. I really recommend giving it a read!

Thank you for the heads up! I've fixed the error so it's linked to the correct resource :)

Collapse
 
malgosiastp profile image
Malgosia

Awesome thank you :)

I think it's not only my struggle, there is a lot of projects like this :D

For me actually, it's not only about fixing it but what's more important for me - introduce good practices and teach my team members about the importance of avoiding !important :D and of course so they are convinced about this not only do it because someone asks :)

Really appreciate the article :) For sure will help me :)

Keep up spreading good CSS practices :)