J
John Hosking
Lupine said:One question about this: I chose to go with styles in the page code
itself. I've been told - and read - that an external style sheet is
more efficient.
Opinions on that?
Executive summary: Usually (so probably), an external stylesheet is better.
Reasoning: Any request for a file from your server entails a bit of
overhead, and each stylesheet is another file. However, caching (at
client or server level) can mean eliminating the request to your server
in the first place.
If you have more than one page of content on your site, and any styles
are duplicated on multiple pages, you're probably* better off moving
those rules to an external stylesheet. That gives you less duplication
in each content page, therefore smaller pages, ergo more of the
efficiency I think you're talking about.
As a webmaster/administrator, it's generally easier for me to put all
the CSS in one stylesheet (okay, I might have more than one for a site,
and I do have separate sheets for print, say), so all the rules tend to
be in one place. I often (but not always) put unique, one-use only rules
in the central, external stylesheet, which (a) helps me locate them and
(b) helps me notice when my styling gets out of hand. So there's another
kind of efficiency to consider.
HTH
* Yes, "probably" is a weasel word, although I can't think of when this
wouldn't be true. Looking around for arguments against.