---
title: Remove Inline CSS and Line Breaks in WordPress Galleries
date: 2011-03-19T22:07:55+00:00
modified: 2011-03-19T22:16:40+00:00
permalink: https://kaspars.net/blog/remove-inline-css-line-breaks-galleries
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
post_tag:
  - How to
  - Snippet
category:
  - WordPress
---

# Remove Inline CSS and Line Breaks in WordPress Galleries

Inline CSS and line breaks `<br style="clear" />` that are automatically added to the image galleries in WordPress is an example of how the needs of Automattic and WordPress.com influence the way new features are added to the WordPress core. So instead of editing every single theme on WordPress.com and adding the necessary CSS for galleries to look good in all of them, they decided to put it WordPress core.

Here is how to replace those double line breaks with a single `<br />` and remove the inline CSS:

```
add_filter('the_content', 'remove_br_gallery', 11);
function remove_br_gallery($output) {
	return preg_replace('/(<br[^>]*>\s*){2,}/', '<br />', $output);
}

add_filter('use_default_gallery_style', '__return_false');

```