HTML: Why we need to format it properly


I have always try to write a Validate HTML, but often I have been asked by my staff member what is the need of validated HTML if everything is working. They ask this question to avoid their little effort in getting HTML in proper shape, as they have to concentrate on open and closing tags etc. But recently I got a perfect example for them. We are using Jquery Ajax in our code where applicable, but soon my developer face a problem that whenever they try to load some dynamic content from Jquery Ajax it fails, but it works with their manual written Ajax code [which is indeed bit unsecure ]. But our problem is not limited to this, the problem we face is that when we add a Dynamic field using Ajax it doesn’t get submitted with Firefox, but it works fine with IE8 [yes you read it correct Firefox create problem for a chance this time]. I struggle to find the solution, because I didn’t look in HTML of their but try JS code only. Later I realise that I should check HTML and there I found a little problem.

The code is using DocType for XHTML 1.0 transitional, but what was written is not a valid xHTML, as the developer put <Form> opening tag between two <tr> tags. In XHTML this is not allowed, a Table Cell or Table element cannot take FORM tag as child, It will work for Table Cell [td], but it won’t work if you put FORM directly in Table Tag. Once the problem is solved, my dynamic fields start getting submitted fine on all browser.

Just little more information, that we were indeed using createElement DOM object, rather than InnerHTML to define our HTML, but still have that problem. So a Valid HTML is what I call a solution.