I'm developing my first really major wordpress plugin and I'm not sure how to approach specificity.

I want to avoid inline styling completely yet I want to ensure my css declarations aren't interfered with by other plugins or themes. While I can and will test it with several different themes before release, I want to ensure that I do everything possible at the dev stage.

So with that in mind, should I maintain a minimum specificity for all my CSS declarations? From my experience, I'm reckoning that if a theme declaration has a specificity higher than (0,1,0,0) then it's likely to be specific to an ID anyway so very unlikely to interfere with my declarations. So as a rule of thumb I've been maintaining a minimum specificity of (0,1,1,0) in my declarations, but I don't know if this is good enough. I'm 99% sure that all my ID's are absolutely unique to my plugin.

Is there any documentation or standards for this that I should work to ensure that my CSS is good?

1 Answer 1


There’s no standard. CSS specificity in themes varies wildly, and I’m convinced many theme authors are not even aware of the concept given some of the CSS I’ve seen.

If something is very important to the appearance of your plugin, then high specificity may be desirable, but in many cases if you’re just styling divs with unique class names, or form elements, then you should keep specificity low so than it can inherit styles from the theme as appropriate.

So really it’s case by case, and you’re not going to be able to guarantee results with all themes. A good rule of thumb is that your specificity should reflect how important it is that the styles are respected.

  • Thanks, very interesting and helpful. I'm adding an admin menu so that the user can change colors and a couple of other styles to match their websites but overall I'd rather lock it down with a high specificity and then give the user the option to control a few specific styles in the backend so that I know I've done my best to ensure the design won't break under most circumstances. Don't want to leave too much to chance in case it breaks. Unless there's a good reason not to do this!?
    – AutoBaker
    Apr 23, 2021 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.