Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body onload="normPara()">
<h1>The Document Object</h1>
<h2>The normalize() Method</h2>
<button onclick="addTextNode()">Add a Text Node</button>
<button onclick="normPara()">Normalize the Document</button>
<p>The document has <span id="cc" style="font-size:20px">1</span> child node(s).</p>
<script>
function addTextNode() {
const textNode= document.createTextNode("Click again. ");
const body = document.body;
body.appendChild(textNode);
const cc = document.getElementById("cc");
  cc.innerHTML = body.childNodes.length;
}
function normPara() {
  document.normalize();
  const body = document.body;
  const cc = document.getElementById("cc");
  cc.innerHTML = body.childNodes.length;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_normalize by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:39:43 GMT -->
</html>