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

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 UTC