JSFiddle - React, Tailwind, and code Playground

by Rolf

HTML

<h1>
Hello &lt;iframe&gt;
</h1>
<iframe id="foo" src="">

</iframe>

JavaScript

const foo = document.getElementById("foo");
const fooDoc = foo.contentDocument;

const html = 
   "<head><style>" + 
   ".pre { display: inline-block; width:2em; height: 1em; background-color: #ccf; }" +
   "</style></head>" +
   "<body>" +
   "<span class='pre'></span> Lorem Ipsum" +
   "</body>";
   
fooDoc.open("");
fooDoc.write(html);
foODoc.close();