Is it bad to use !important in a CSS property?

!important is a useful tool, but the drawback is that it’s kind of a tool of last resort. So you don’t want to over-use it as you’ll end up causing headaches down the road for anyone that’s maintaining the site.

However, your example is a typical use. What is happening is that the JS is injecting inline style attributes on the fly. As such, that’s over-riding the cascade in your CSS. !important allows you to over-ride that.

Leave a Comment