srcdoc is a much needed attribute, but specifying an entire HTML document inside an attribute is clumsy. On the other hand, I understand that just using the <iframe>
’s contents was not feasible due to all the old markup using <iframe>
contents as a fallback for non-iframe supporting UAs.
Being able to use srcdoc
as a flag alleviates this compat problem, and enables us to use the <iframe>
contents as the srcdoc
.
I’m not sure if any UAs do weird things when there’s an entire other document inside <iframe>
but since they do not process its contents, I suspect it’s probably ok, unless the document inside has iframes, in which case UAs will probably treat the </iframe>
closing tag as the closing tag for the outer iframe. However, in these cases, or in cases where this might happen (e.g. dynamically generated content), authors can always put the document inside the srcdoc
attribute.