Re: Javscript: Creating a self-closing img tag with createElement?
If you are working against an HTML (as opposed to XHTML) DOM, there is no need to explicitly close a unary tag (like <img>, <hr> or <br>). The HTML does not appear in the source in any case; it only exists in the modified DOM (which may be accessible using something like View Rendered Source, the developers' toolkit or a debugger). Since what you are seeing is not source code but an HTML rendering of the DOM as it exists in memory, the viewer will render whatever the valid representation of that element happens to be. Strictly speaking, the slash at the end of a unary tag in an HTML document is an illegal garbage character, even if it is required in XHTML (which is a dialect of XML that only superficially resembles HTML).
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)