I was working on a web page generation program recently and was looking for a way to present different versions of the same page with slight differences in the markup and styles. Although using the iframe element came to mind I wasn't keen on rendering out lots of different versions of the page and then referencing them individually in each iframe. I did think about creating using an API to send back each page on request but I thought that this might just overcomplicate the program.
After a little bit of research I came across the srcdoc attribute of the iframe, which solved the problem quite neatly.
The iframe is normally used with a src attribute, which points to some external page. The following example will render the page at example.com within the page.