-1

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)

  • Just so people don't think I'm crazy, this person believes it too! http://www.f15ijp.com/2010/11/internet-explorer-not-rendering-empty-div-correctly/ – Ben Sarah Golightly Dec 03 '17 at 13:09
  • 1
    Like the bug report you linked in a comment, that's about *rendering* the element, not removing it from the DOM. And even IE6 renders a div with nothing in it but with a background and height just fine (I just checked), so that blog post seems highly suspect. – T.J. Crowder Dec 03 '17 at 13:27
  • *(Sorry, linked in an answer below, not a comment.)* – T.J. Crowder Dec 03 '17 at 13:38

2 Answers2

3

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. :-)

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
-1

According to this bugzilla entry, 18 years ago Netscape Navigator 4 had this problem with empty table cells in quirks mode.

This has no relevance today but might be the source of the rumour.

  • 2
    That's not what that bug report says. It says it didn't **show** table cells with no content (e.g., didn't show background color, borders, etc.), not that it **removed** them. (And indeed that was the case, also with IE and even Firefox for a while.) – T.J. Crowder Dec 03 '17 at 13:25