<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script> function boom() { // Force frame construction document.documentElement.offsetHeight; // A dynamic change var x = document.getElementById("x"); x.firstChild.remove(); x.appendChild(document.createTextNode("\n\n\n")); } </script> </head> <body onload="boom();"> <div style="direction: rtl; white-space: pre;"><span style="outline: 1px solid red;" id="x"> :p</span></div> </body> </html>