WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

currently, I use CSS specificity to override plugin styles. I prefer this to editing the plugin as it makes for less headaches when you update.

What would be nice is if my style sheet loaded after the plugins, so that I only have to be as specific, not more. This would make my stylesheets much prettier.

share|improve this question
up vote 15 down vote accepted

As you suggest, the most elegant approach is when your CSS overrides are loaded after the CSS injected by the plugins. This is quite easy to achieve - you just need to make sure that your header.php calls wp_head() before it references your style sheet:

    <!-- all the usual preamble stuff goes here -->

    <?php wp_head(); ?>

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
share|improve this answer
Hey, that's a really nice solution Tim. – Dwayne Charrington Jan 9 '11 at 4:56
Great idea, so simple!! It does assume the plugins use wp_head, but I can't think why any wouldn't. – Mild Fuzz Jan 10 '11 at 11:09
And what if I'm using a child theme? I don't like to override the header.php of my parent theme. – Jules Nov 7 '12 at 10:10

There are several ways plugins can handle CSS.

  • best case: plugin queues CSS and provides option to disable it (disable it, copy CSS code to your stylesheet and be happy);
  • good case: plugins hooks function that queues style (unhook function, hook your own with mods if needed);
  • usual case: plugin queues CSS directly. See How to dequeue a script? (applies to styles as well). Short version - there will be dequeue function in future WP release, for now could work around with wp_deregister_*
  • bad case: plugin echoes CSS among bunch of other things. Case by case...

Overall in my opinion it is better and easier to disable separate stylesheets and incorporate them in your own to minimize issues and improve performance (less files to fetch).

share|improve this answer
How would I know which one it is? – IanEdington Nov 18 '15 at 0:30
By looking at the code mostly. :) – Rarst Nov 18 '15 at 8:36

I save a copy of the "not willing" plugin CSS to the theme folder and import it into the theme css by adding

@import url('name-of-the-plugin-css.css');

to it (replacing, of course, the name of the .css by the one I'm injecting). Then I modify the css copy in the theme folder and save it to server as I do for the other files. Oh, yes, sometimes it may be necessary to "nail" the IDs or classes altered by assigning them an "!important".

I do not know if this is state of the art, but it does no harm and works just fine.

share|improve this answer

Another quite elegant way is to use specificity of CSS.

So if the css of the plugin says:

div.product div.images img {

you define in your css:

body div.product div.images img {

Also see the answer of Michael Rader for a similar question.

share|improve this answer
Ok thank you very much. This would be the accepted answer for me. Just use the general style.css and specificity works like a shine! – Stratboy May 18 '15 at 9:44

To override the css of plugin, that was already using specificity and !important, I used the id to override the classes. This did clean up my code a bit. Of course, it too is not a perfect solution in that it only works when if there are id's assigned to elements as well as classes.

You could also use attribute selectors in theory. However, I have yet to put that theory to test.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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