WordPress plugins have the ability to include their own CSS files and most of the time this is great. Good plugins will write selectors that only affect the plugins content but some of the plugins don’t write specific enough CSS or their CSS uses techniques that make it more challenging to override with your own CSS. Regardless of the reason I knew there had to be a better way to allow your own styles to be applied to the content.
I knew that WordPress has the ability to register & deregister script/style files but I was primarily finding solutions which use CSS specificity to override the styles. This works just fine but that’s an awful lot of work I would prefer not to do. Besides, there is no need to override the styles and clutter your own stylesheet when you can simply prevent the file from being sent in the first place.
All you have to do is add an action right before the styles are sent to the browser.
In this action you simply list the handle(s) of the file(s) you want to ignore. You can easily find the handle in the plugin’s file in the wp_enqueue_style() method. You can dequeue as many files as you need inside of the mytheme_dequeue_css_from_plugins() function. You can even dequeue script files if you need to.