Static html can be checked using a strict HTML parser. However, you could check generated code too, for early validation and debugging. Send it off to the validator and write it out to the socket. Or, use a proxy on the client side, which would be a nice general-purpose tool.
I agree, I hate IE in how it encourages sloppy and incorrect code.
Somewhat related:
Apache::ProxyPassThru with Apache::DumpHeaders (or Apache::DumpHeaders alone if you are debugging that server) is a really really useful for figuring out what's going on when things seems to go wrong with that kind of thing.