We want to customize a lot of things in our WordPress themes, and WordPress gallery style can be one of those. At first, it looks like to throw some CSS code in the style.css and it’s done. But that alone, is not gonna work since WordPress automatically adds a default style snippet in the post containing the gallery, and this overrides all of your CSS code coming from style.css or anywhere else.

Dandelion WordPress Theme Gallery

Example of Custom Gallery on Dandelion WordPress Theme

So, the hurdle in our way to customize our gallery look is that automatically added style snippet. Once we restrict the addition of this default style, we are almost done.

How can I remove the default gallery style in WordPress?

So, what else I need to do to get this done? Well, this can be accomplished by telling WordPress not to add that style code segment in the post containing a gallery. We can do that by adding the below hook in functions.php of our WordPress theme:
add_filter( 'use_default_gallery_style', '__return_false' );

Now, save the functions.php file and add your custom styles to style.css and test a gallery. Bang! Your custom WordPress gallery styles are now working!