Rich-text Reply

Overriding !important tag

amymcsharry 05-13-16

Overriding !important tag

I am trying to set up (one of my first) experiments and I have an important tag relating to the font style/size on my site and can't figure out how to override that for my experiment. I'm a product manager with extremely limited CSS training, so I'm jsut trying to see if I can somehow override it with some basic CSS code before I have a developer take time away from more complex tasks to deal with this. Any suggestions would be greatly appreciated!

JDahlinANF 05-13-16

Re: Overriding !important tag

@amymcsharry - there are some good suggestions on StackOverflow about how to override it.


My preferred method is to create a more specific CSS rule.


for example, if the current CSS is like:

.some-element { color: #00FF66 !important; }

I will inject CSS like:

div.some-element { color: #77aa22 !important; }

You inject CSS like this:

$('head').prepend('<style>div.some-element { color: #77aa22 !important; }</style>');