<!doctype html>
<p>
Both lines below should look the same:
</p>
<div id="target" style="display: flex; white-space: pre;"></div>
<div style="display: flex; white-space: pre;">A B</div>
<script>
target.appendChild(document.createTextNode("A"));
target.appendChild(document.createTextNode(" "));
target.appendChild(document.createTextNode(" "));
target.appendChild(document.createTextNode("B"));
</script>