If you've ever worked with hidden fields in IE7, you may have stumbled across this when viewing code like this:
<form>
<input type="hidden" />
<span>Hi, I'm text!</span>
</form>
| You expected to see this: |
But you end up with this: |
|
Hi, I'm text!
|
Hi, I'm text!
|
This is due to a bug with how IE7 handles hidden input tags directly inside a form element. For whatever reason, when IE7 sees a hidden input tag with any white space or line breaks between the end of its tag and the beginning of the next tag, it adds an empty line to the rendered version. This seems to only effect direct descendents of the form element, though.
You can fix this in a few ways:
- The "Hacky Fragile" way: Remove any white space between the hidden input tag and the next tag.
- The "Meh" Way: Put all your hidden inputs at the end of the form tag.
- The "Recommended" way: Wrap the hidden inputs inside of another tag, like a div.