CSS includes + HTTP headers = big mess

Anne van Kesteren just posted about the Opera 9 Preview.  More notable to me is the testcase for Linking to style sheets with HTTP headers.

Here’s the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
  <title>CSS: Linking to style sheets with HTTP headers</title>
  <meta name="Author" content="Krijn Hoetmer ~ http://ktk.xs4all.nl/">
  <h1>Linking to style sheets with <abbr title="HyperText Transfer Protocol">HTTP</abbr> headers</h1>

  <p>This line should (or could) be red.</p>
  <pre><code>Link: &lt;index.css&gt;; REL=&quot;stylesheet&quot;; MEDIA=&quot;screen&quot;</code></pre>


The testcase already works (P element in red) in the current Firefox 1.07 (but not IE, natch).  Style code is utterly missing from the document — there are no style attributes, and no <style> or <link> elements.

That’s because they’re not in the document.  It’s in the headers of the HTTP response which delivered the document.  I had to find the style insertion with the Fiddler tool (a great IE addin), and this is what I found in the HTTP headers:

Link: <index.css>; REL="stylesheet"; MEDIA="screen"

I must’ve missed the memo where this became a standard (since multiple browsers now support it).  I miss how it’s a good idea too…

Yes, there’s a gee whiz factor to it.  I could even think of possible uses for HTTP style includes (like configuring includes at the website level via the web server, something which IIS already can do with normal include files). 

But it just seems like a bad idea.

Granted, the line between protocol and document was crossed long ago with HTTP-EQUIV META tags.  This, however, crosses it in the opposite direction, by putting not meta-data, not layout or behavior data, but style data into a transport protocol!

Now I’m no code purist — I feel most like a “SAVD” on Molly’s scale  (What’s bizarre is that I’d consider Anne much closer to a purist, a “SASS” to Molly.) 

We have CSS to get the font tags out of HTML.  Why not cram it into something even more poorly suited like HTTP?!

VERY bad idea.

Bookmark the permalink.

4 Responses to CSS includes + HTTP headers = big mess

  1. Jero says:

    &lt;blockquote&gt;I must’ve missed the memo where this became a standard&lt;/blockquote&gt;
    <br>This method has been standardized when HTML 4 became a standard:
    <br><a target="_new" href="http://www.w3.org/TR/html4/present/styles.html#h-14.6">http://www.w3.org/TR/html4/present/styles.html#h-14.6</a&gt;
    <br>Of course, this isn’t something that you’ll be using over a &lt;code&gt;LINK&lt;/code&gt; or a &lt;code&gt;STYLE&lt;/code&gt; element when you’re making a web page, but in some cases, where <a title="" href="" ><acronym title="HyperText Transport Protocol">HTTP</acronym></a> is also involved, it can be quite useful. Like the example given in the last paragraph: email.

  2. liorean says:

    It’s defined in [HTML4.01] 14.6 Linking to style sheets with <a title="" href="" ><acronym title="HyperText Transport Protocol">HTTP</acronym></a> headers and would have been in in <a title="" href="" ><acronym title="HyperText Transport Protocol">HTTP</acronym></a>/1.1 if not for lack of implementations at that time.
    <br><a target="_new" href="http://www.w3.org/TR/REC-html40/present/styles.html#h-14.6">http://www.w3.org/TR/REC-html40/present/styles.html#h-14.6</a&gt;

  3. Rob says:

    BTW, linked styles in email (either normal or <a title="" href="" ><acronym title="HyperText Transport Protocol">HTTP</acronym></a>) is ALSO a bad idea, but for security reasons. It’s yet another way to run &quot;web bugs&quot; (thus far accomplished with linked styles, scripts, images, IFRAMEs, etc), which are why many people only do plain text email these days. (I miss being able to count on bold, italic or the occasional color).
    <br>Anyway, these are web browsers, not email clients.

  4. Little Penguin says:

    I do not think it is a big mess, if implemented well on all browsers we have the possibility to seperate all links to a style(sheet) from the HTML or <a title="" href="" ><acronym title="eXtensible Markup Language">XML</acronym></a> document.
    <br>The reason nobody knows about this is because Internet Explorer failed to implement this handy feature. I hope <a title="" href="" ><acronym title="Internet Explorer">IE</acronym></a> will support this too, because it is then possible to attach a stylesheet independant of the contents of the HTML (change a link to a stylesheet, eg use another file or add a file) with the addition of 1 line to .htaccess or the server configurations…

Leave a Reply

Your email address will not be published. Required fields are marked *