Search code examples
htmlinternet-explorerlegacy

Does Internet Explorer (still) remove empty elements from DOM?


At least at one point in the past, Internet Explorer would remove empty elements from the DOM.

So the elements:

<div id="something"></div>
<span></span>

Would never appear, could not be targeted by JavaScript, etc.

The common workaround was:

<div id="something">&nbsp;</div>
<span>&nbsp;</span>

Do any non-EOL versions of Internet Explorer still have this behaviour?

What versions of Internet Explorer have/had this behaviour, or was it a myth? (The advice was common when IE6 was around)


Solution

  • I've been doing web development off and on since 1996, and I've never seen IE do this, nor heard anyone say that it did.

    I happen to have an old Windows 2000 VM lying around with IE6 on it, so I fired it up and tried it: No, it doesn't remove those elements.

    I'm quite certain no non-EOL version of IE does this, and fairly certain no EOL'd version did. :-)