Using css via a css file
Hello, I am looking to make my new site compliant in Netscape 4.x, 6., and IE 5.5, and 6.
My question lies in the fact that I want to use a css file instead of having css code at the top of every page. Instead would just link to the stylesheet,
My question is: Does netscape have trouble doing such a thing? Are there any pros/cons to doing this?
<link rel="stylesheet" href="silence.css">
Any insight would be appreciated.
As far as I know, NS4 has no trubble using a stylesheet <link>, but can't read the @import rule of CSS2.
There are many pros with using external files mostly revolving around consistency, code reuse, and browser cashing. However, using a sepperate file does entail another round trip to the server for the client to retrive the stylesheet. The bottom line is that you'll probily want to use a <link> if you have several pages using the same or simular stylesheets, but for just one page, it may not be worth it.
If you do use <link>s than you must include a type attribute in the <link>: in your case 'type="text/css"'. Oh and also, you can use the <link> eliment to bring in a standard stylesheet and use the <style> to modify it for the particular page.
~~Hope This Helps
This is the way I do it (works with Netscape also).
Including the css-file has the advantage that changing only one file (maybe even one line) can change the style in the rest of the css-linked pages.
Cool. Sounds like it is the direction I want to head in. Thanks guys!
You might want to also check out the master class on this site as it goes into how you can get your pages to work in all browsers, what works what doesn't, best layout all for css... worth a read honest ;)
Thank you Sarah. I will check that out right now before I head to bed. :)
I would advise reading it with a clear head ;) otherwise you'll think its all gone mad :D
(in all fairness Creole pointed it out to me and well I have been advertising it ever since :) )
I just passed it on myself. I can't remember who first gave that link to me. One thing I will point out though that I don't like about the RichInStyle "template stylesheet" is the fact that they use em as their unit of measurement.
em cascades through the stylesheet which means that child elements will inherit the defult style of the parent and then apply their own style. This means that if I set BODY and P to .9em the BODY text will be the proper size but the P tag will be .8em (or whatever the math would be) because it first uses the parent elements style (.9em) and bases it's size from that.
This is only a problem with the em unit of measurement.
I know what you mean - but then the whole font stuff did my head in a bit, I stick to what I knwo works and that will do me fine.
Also you know the "standard" css sheet why does he use the UL LI OL all the way across?
Do you have php? You can serve up links to browser specific .css files if you do, or even include them on the page (bypassing any <link> issues). Alternatively, use simple css that won't choke ns4x with the <link> way and any fancy stuff for NS6-IE5+ with the @IMPORT way - that way you can get good performance across browsers.