W3C home > Mailing lists > Public > www-style@w3.org > December 2000

Re: <link> vs <style></style>

From: Sampo A Syreeni <ssyreeni@cc.helsinki.fi>
Date: Sat, 16 Dec 2000 17:06:11 +0200 (EET)
To: Ben Morris <bmorris@activematter.com>
cc: <www-style@w3.org>
Message-ID: <Pine.SOL.4.30.0012161701590.17808-100000@kruuna.Helsinki.FI>
On Fri, 15 Dec 2000, Ben Morris wrote:

>This may be slightly off topic, but I was wondering if anyone can tell me
>advantages/disadvantages by using styles within the <head> tags of each page
>as opposed to using the <link> tag and a .css file.  Obviously, using the
>latter would make each .htm file shorter, and reduce some download time for
>that file.

Links let you gather the stylesheet rules of your site to a single, easily
maintainable stylsheet. Reuse is the key, here. But your browser can only
start downloading the sheet when it has already fetched at least the head
portion of your document, which means that you get two separate HTTP queries
and possibly a lot of latency in between them. This is even more of a
problem when the stylesheet @imports others.

>The alternative would be to use a server-side include to insert the code in
>each page, which would offer the same sort of easy maintenance.

Indeed. It's a tradeoff. Plus, your SSI stuff will let saved pages work
offline, unlike the linking one. But if you have a sizable stylesheet, the
duplication adds to latency as well. Especially since once a linked
stylesheet has been fetched for the first time, it should remain accessible
in the browser's cache. This is the second benefit of reuse.

Sampo Syreeni <decoy@iki.fi>, aka decoy, student/math/Helsinki university
Received on Saturday, 16 December 2000 10:06:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:06 GMT