This is the briefest of posts, because the content is entirely thanks to the wonderful xkcd comic, and it’s pretty damn nerdy.
First person in the comments to exclaim that they get it, and can give some sort of rationale, gets a prize.
via xkcd: Tags.
The SPAN element has very similar properties to the DIV element, in that it changes the style of the text it encloses. But without any style attributes, the SPAN element won’t change the enclosed items at all.
The primary difference between the SPAN and DIV elements is that SPAN doesn’t do any formatting of it’s own. The DIV element includes a paragraph break. The SPAN element simply tells the browser to apply the style rules to whatever is within the SPAN.
To open a DIV tag without closing it but instead to close a SPAN tag that was never opened creates an interesting conundrum for the browser, resulting in unpredictable and possibly inconsistent layout behavior. It vis the coding equivalent of “The following statement is true. The preceding statement is false.”
Gabriel, that is a much more complete answer than I was expecting!
Email me your address to peter@petermahoney.com, I’ve got something coming your way.