For example, in the following HTML …
<form name="outerform">
<input type="text" name="outer1"/>
<input type="text" name="outer2"/>
<div>
<form name="innerform" method="post" action="#">
<input type="text" name="inner1"/>
</form>
</div>
</form>
Firefox will simply throw away the innerform <form> tag, since forms cannot be nested.
I ran into this while patching some legacy code. Someone had placed a <form> tag covering almost the entire body content. When I added my own, more localized <form>, Firefox stripped out the inner tag and my submits were going to the outer form. Since I was doing some jQuery processing to create my submit URL, I thought it was my error. I realized the problem after viewing the rendered HTML in Firebug’s HTML tab.
If the browser, or Firebug had a tab for “ignored HTML”, or some such method I would have picked it out immediately. I can’t simply do a View-Source and paste it into the W3C’s web-based validation service for the following reasons:
- For security reasons, the development computer I’m on is not connected to the public Internet.
- Firebug’s HTML tab shows the rendered HTML, so the invalid HTML tag has already been removed.
Finally, the editor (Eclipse) is usually where I catch bugs like this. But we use a lot of included files and the Tiles framework, so you only see a fragment of the final HTML page at a time.
I found my solution. Thanks to Boris Zbarsky’s comment for pointing me in the right direction. The view-source shows the downloaded HTML, but the Firebug DOM inspector shows the rendered HTML (I was mistaking the two in the question). Solution:
<html>, Copy HTML, and save to file (File 2)Reformatting the HTML in the two files might make diffing easier.