W3C home > Mailing lists > Public > www-validator@w3.org > September 2016

Re: Iframe alternative content

From: Michael[tm] Smith <mike@w3.org>
Date: Sat, 3 Sep 2016 02:14:25 +0900
To: David Dorward <david@dorward.me.uk>
Cc: "www-validator@w3.org" <www-validator@w3.org>
Message-ID: <20160902171425.lmwn6mla2gbbduos@sideshowbarker.net>
David Dorward <david@dorward.me.uk>, 2016-09-01 14:26 +0100:
> Archived-At: <http://www.w3.org/mid/84312495-6F57-43A9-A276-929101E5A6AA@dorward.me.uk>
> 
> I was somewhat surprised when reading the spec for iframes to come across
> the [content model][1] rules.
> 
> > When used in HTML documents, the allowed content model of iframe
> > elements is text, except that invoking the HTML fragment parsing
> > algorithm with the iframe element as the context element and the text
> > contents as the input must result in a list of nodes that are all
> > phrasing content, with no parse errors having occurred, with no script
> > elements being anywhere in the list or as descendants of elements in
> > the list, and with all the elements in the list (including their
> > descendants) being themselves conforming.
> 
> This is a change from HTML 4 where it could contain %flow content which
> included block elements.
> 
> The nu validator seems happy with `<iframe><p>Test</p></iframe>` though. Is
> this is bug or am I misunderstanding the spec?

The spec should be more clear about this, because as it’s written now, the
part that’s maybe the most important thing for authors/developers to understand
is in the note that follows the language cited above. That note says:

> The HTML parser treats markup inside iframe elements as text.

So if the HTML source of a document has `<iframe><p>Test</p></iframe>`, an
HTML parser puts all of that `<p>Test</p>` part into the DOM as text—that
is, there is no `p` element in the DOM for that.

You can verify that by using browser devtools/inspector or this:

  https://software.hixie.ch/utilities/js/live-dom-viewer/<iframe><p>Test</p></iframe>

Anyway, I think times the only reason the spec actually ever allowed any
content at all in `iframe` elements was for fallback in very old browsers.
Notice that for the case of HTML documents served with an XML mime type,
the spec says:

> The iframe element must be empty in XML documents.

We should probably change the spec to say that same for text/html documents—
because at this point I don’t think we have any people any more using
browsers that don’t have iframe support.

  —Mike

> [1]: https://www.w3.org/TR/html5/embedded-content-0.html#iframe-content-model

-- 
Michael[tm] Smith https://people.w3.org/mike

Received on Friday, 2 September 2016 17:14:52 UTC

This archive was generated by hypermail 2.3.1 : Friday, 23 September 2016 09:38:19 UTC