External style tag

2014-02-13

I don't write much html these days. I'm a JS guy. So when I do and I have to include an external style sheet I always have to lookup the actual link syntax from another project or google. So annoying.

Legacy is nice, but forward thinking might be too. I don't really understand why we can't have src on style tags. This can all be done in a perfectly backwards compatible way. Even the transition period can be quite elegantly fixed. Here's another one of my "wishful thinking" (tm) proposals...

Current (minimal) situation:

Code:
<link href="app.css" rel="stylesheet">

Desired situation:

Code:
<style src="app.css">

Perhaps with overrides for sheets in other languages like sass or less, language= would help there, just as with <script>.

Transitional period:

Code:
<link href="app.css" rel="stylesheet" unless-script-src>
<style src="app.css"></style>

Yes, you'd need two tags for the same content for a while. But that means that in a not-too-far-future we can actually use <style> tags for external stylesheets, rather than <link>s! The required closing tag would also count, just as with <script>.

The unless-script-src attribute is a boolean attribute that serves as backwards compatibility flag to prevent double loading of the resource. Old browsers don't need to know about it and will ignore the empty <style> tag. New browsers will ignore the <link> tag in favour of the <style src="url">. Huzah! Of course, unless-script-src can be bikeshed into anything. Even ignore, html5, or dont-give-a-hoot.

It's not like <link> isn't already burdened with many attributes anyways.

I could write a polyfill for this, but really?

Let's just make this happen, yes?