How to stop WordPress from Hijacking your HTML
Posted in How To's on October 26th, 2010 by Maurice Kindermann
While doing my last post I couldn’t get an image aligned the way I wanted it using the default WordPress tools( Insert Image -> align right). I generally prefer to write in HTML because it gives me full control. WordPress uses a modified version of TinyMCE which has a javascript cleaning script which will try to ‘correct’ your markup. Markup is basically a fancy way to describe HTML for web design. Generally speaking markup cleaning is great, but for veteran HTMLers it can be frustrating.
After a quick Google I found this: http://wordpress.org/extend/plugins/raw-html/ (there really is a plugin for everything!)
The WordPress Plugin ‘Raw HTML’ gives you the ability to insert tags that will stop TinyMCE from hijacking your code. It basically will leave all HTML, CSS and Javascript within these tags alone. There are the tags it uses on the HTML view:
<!--start_raw-->
HTML / CSS / Javascript
<!--end_raw-->
Unfortunately the problem I had with image alignment was not fixed, because by default WordPress will wrap all line breaks in paragraph tags (<p></p>). Oh well, I’m sure this will come in handy in the future anyway! Back to being a humble Brisbane Website Designer.