W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2013

[whatwg] [html][webcomponents]: Link element in body?

From: Benjamin Stürmer <benjamin.stuermer@gmail.com>
Date: Wed, 20 Mar 2013 11:27:51 +0100
Message-ID: <CADxW5ac-R9TG7zSicFJiaEofxYKB-Ud6tFSzBC+=kYVk7W3GUA@mail.gmail.com>
To: whatwg@lists.whatwg.org
> On 3/19/13 11:18 AM, Brian Kardell wrote:
> > Section 4.2.4 of the HTML Standard[1] contains a note:
> > "Note: If the rel attribute is used, the element is restricted to the
> > head element. When used with the itemprop attribute, the element can
> > be used both in the head element and in the body of the page, subject
> > to the constraints of the microdata model."
>
> That's an authoring requirement, like pretty much everything to do with
> element content models.
>
> As in, if you have a <link> without itemprop but with rel inside <body>
> your HTML validator will complain at you (and chances are your page will
> end up with FOUC and whatnot, which is why this is not something the
> spec makes valid).
(My first post to the list. Hi there! Please let me know if I violate
any conventions I haven't picked up on while lurking.)

I've been thinking about this exact thing for the last few weeks,
because I have a use case in which it would be beneficial to use an
in-body <link> to include CSS files, especially if <link> could be
updated to support the "scoped" attribute with the same behavior as in
<style>.

My use case is a CMS in which editable content is loaded into an
editor overlay via AJAX. This creates a bit of a nightmare due to the
need to keep strict separation between rules that apply to page
content and those that apply to the editor overlay, otherwise you end
up with the editor overlay getting styled by rules meant for the
content. I've solved the problem by introducing namespacing rules for
CSS selectors, but a much more elegant solution would be to include
CSS via scoped <link>s.

I don't think that FOUC in and of itself is a strong argument against
allowing behavior like this. In my use case, FOUC wouldn't actually
occur, and in any case I suspect that authors to whom issues like FOUC
are important are aware of the significance of where they include
their CSS in their documents, and authors to whom issues like FOUC
aren't important aren't running their markup through validators in any
case.

~ Benjamin Stürmer
Received on Wednesday, 20 March 2013 10:28:15 GMT

This archive was generated by hypermail 2.3.1 : Wednesday, 20 March 2013 10:28:15 GMT