same as title, I'm pretty sure it has no difference, but just to be on the safe side with standard compliance.
If your document is served as XHTML (application/xhtml+xml
), then there is no difference. If it's served as HTML (text/html
), only the first form is going to be parsed "correctly" by an HTML parser.
See this post for a related question.
No difference. Self closing tags are just the short way of getting the same job done.
just like c++ is that same as c+=1 and c=c+1 ... just cuts down on typing.
No there is no difference for any XML element in any XML document.
<img .../>
is just a shortcut for <img...></img>
<img />
is the recommended way: http://www.freewebmasterhelp.com/tutorials/xhtml/2
This is not just a theoretical different in what is parsed "correctly". There's actually a practical difference.
When served as text/html to browsers other than IE, the "/" in the first case and </img> in the second case will be ignored, and the DOM created in both cases will be the same.
In IE however, in the second case the </img> is not ignored and results in an additional element in the DOM called "/IMG". It's possible for this to effect the workings of scripts that might be on the page.