I am trying to understand why is there a difference in how a browser displays
verses ?Here is an example: The expected
As you have clarified that you're using HTML5... from the HTML5 spec:
Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS character (/). This character has no effect on void elements, but on foreign elements it marks the start tag as self-closing.
The void elements are:
area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr
The foreign elements are those from the MathML and SVG namespaces. As you can see, none of these elements are the div element, and therefore your second example is invalid HTML5.