The closing tag of an img
element is entirely optional - this won't cause you problems in any browser. So much so, in fact, that in HTML5 you're now not supposed to include the />
in img
elements at all.
Also, what you see when you inspect the DOM is just how your inspector chooses to display elements with no closing tag - you can be sure that createElement()
and appendChild()
are generating valid HTML, as you're working directly with the DOM rather than providing text for the browser to parse into DOM objects.