Whitespace preservation and the DOM

Any white space that you add to a webpage persists in the Document Object Model (DOM).

Any white space that you add to a webpage persists in the DOM when using Windows Internet Explorer 9.

If you want behavior like Windows Internet Explorer 8, use the Element Traversal API (for example, firstElementChild).

Consider how the following code example appears in Internet Explorer 9 and Internet Explorer 8.

<div>
   Text </div>

Internet Explorer 9:

     div
              |->"\n   Text "

Internet Explorer 8:

     div
              |->"Text"

Element Traversal API