Generally if there is text between tags in HTML, it becomes a text node. However, this is not always the case. Consider this example:
<p>
<a href="hello.html">hello</a> <a href="world.html">world</a>
</p>
Here, the linebreak and 2 spaces between the <p>
and the first <a ...>
won't appear as a text node in the DOM, at least not in Chrome. hello
and world
will of course be text nodes. It would seem that sequences of only whitespace don't appear as text nodes, but that's not always the case: In this example, the space between the 2 links is a text node.
How does Chrome decide what becomes a text node?