I have always and will continue to always close an HTML input such as
<input type=text />
instead of the non-XHTML way
<input type=text>
But my question is, will either way have any foreseeable problems i.e. cross-browser, mobile device, etc? I’ve just now noticed that the framework I use generates inputs without a closing tag and I hate have differences between my code and theirs. It’s really annoying and ugly.
Personally, I’ve never seen a cross-browser problem on account of closing an empty tag in an HTML document.
However, according to Refactoring HTML, older browsers such as Netscape 3 will not parse empty elements properly.
This is because in SGML and some HTML4 parsers, there was support for a syntax “NET” which is similar to the empty tag syntax: (quoted from XHTML Considered Harmful)
So, if you’re using a HTML4
<!DOCTYPE>and targetting Netscape 3, don’t do it! But if you’re using HTML5 (or XHTML) there’s no harm in closing your empty tags – as a matter of fact in XHTML you have to, or Tim Bray will kill a puppy.