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

Re: [whatwg] Link element in body?

From: Ian Hickson <ian@hixie.ch>
Date: Thu, 1 Aug 2013 21:27:00 +0000 (UTC)
To: Benjamin Stürmer <benjamin.stuermer@gmail.com>
Message-ID: <alpine.DEB.2.00.1308012122460.9685@ps20323.dreamhostps.com>
Cc: whatwg@lists.whatwg.org
On Wed, 20 Mar 2013, Benjamin Stürmer wrote:
> 
> 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.

This is on my radar, but note that in the meantime you can use:

   <style>@import "my.css";</style>

At some point I plan to see how common it is for <style> elements to have 
@import rules; if it's common, then it would make sense to allow <link> in 
<body> for scoped style sheets as well. I hesitate to do it without a body 
of evidence showing it would be used a lot, because it's difficult to 
convey that <link rel="stylesheet scoped" href=""> would be allowed, while 
still having <link rel="stylesheet" href=""> and <link rel="next" href=""> 
non-conforming. I think authors would have more difficulty with the idea 
that certain rel="" values are ok in certain places, than they would with 
the idea that certain attributes are ok there and others aren't. (With 
microdata, it's easier, because we just don't allow rel="" at all.)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Thursday, 1 August 2013 21:27:27 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:23 UTC