When you are adding HTML in WordPress in the text mode, after adding when you go back to the Visual mode you will see codes getting stripped out. There’s nothing wrong with the code, it’s just that WordPress auto formats the code and the spaces in your code. When spaces are formatted the codes are changed and so does your output in the Visual section. This is the WordPress thing and there’s nothing anyone can do about it. One way to go about it is to remove the extra spaces and do the formatting before hand and then paste it in the Text version. However, if you type directly in the Text box then even this method fails. In cases like that the best possible work around is to simply disable formatting by the use of this WordPress plugin.
Simply, install this WordPress plugin and say goodbye to auto format feature of WordPress.
Here are the features of this plugin:
1) Disable auto format check box: This plugin adds a “Disable default WordPress formatting in posts and pages” check box in the Writing settings under Settings in your WordPress blog. To disable auto formatting, you need to check this option and click on “Save Changes”.
2) Disable auto format for individual posts and pages: You also have the option to disable default WordPress formatting for individual posts and pages.
3) Shortcodes support: You can also use shortcodes for disabling default WordPress formatting.