How does wordpress add ‘style’ attribute to element

WordPress of course does nothing so it might be a plugin do this, or a custom theme function.

How does this happen? The plugin may use the_content filter to find all “” element and inject content. Or it can be a visualize text editor with JavaScript code that modify content itself without applying a filter.

It’s hard to give a correct answer for this kind of issue. If I were you, I will do these steps to find the plugin create that shit:

  • Switch to another theme and see if problem is stil there.
  • If yes, try to manually search in the theme file.
  • If not, then problem is plugin, not theme. Try to disable plugin one by one to find out which plugin is the root cause. Then disable it.
  • You should get a local copy of site and work with it because sometimes disable a plugin can affect the site working properly.

If for some reason, you cannot do that, then try do this:

  • Try to disable JavaScript completely. You will get a weird WordPress admin panel. However you are still be able to add a new post. Try to see if that piece of code did’t get inject. If yes, then try to do below step.
  • Do a search to find out that exactly string in which file.
  • Do a search to find out similar string in whcih file: for example try to find “style=” string in *.php file only. You just need to search on wp-contents folder

Once you found out the plugin, just disable it. DON’T ever think of modifying it. Just disable and remove it. A plugin which is injecting that code must be maintain by a bad developer.