Forum Moderators: not2easy

Message Too Old, No Replies

Accessing a CSS file from another HTML doc

I can do it

         

Essex_boy

8:29 pm on Nov 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Im using CSS for teh first time and love it however I would now like to build a seprate CSS file and have my HTML files access it.

How do I tell the HTML to go and use it?

encyclo

8:34 pm on Nov 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The easiest way is to use a link element in between your
<head>
and
</head>
tags:

<link rel="stylesheet" type="text/css" href="your-css-file.css">

Essex_boy

8:57 pm on Nov 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<link rel="stylesheet" type="text/css" href="your-css-file.css">

OK thanks, so Rel means what? Type means expect a CSS file and href is file name.

So my CSS commands would then be formated according to my external style sheet?

Nothing else to be done?

Span

9:00 pm on Nov 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes. And don't put <style> or <!-- comment --> tags in the .css file.

Essex_boy

9:02 pm on Nov 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



AHHAHHAHAH Now I know what Iwas doing wrong! Id put <!---- tags in .

Thanks

Lance

9:05 pm on Nov 4, 2004 (gmt 0)

10+ Year Member



But /* Comment Tags */ are okay, aren't they?

<added>Timing is everything...</added>

[edited by: Lance at 9:08 pm (utc) on Nov. 4, 2004]

encyclo

9:06 pm on Nov 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't forget the extremely useful CSS validator [jigsaw.w3.org] which will help identify any problems with the stylesheet. The CSS file should only include the CSS rules, with no HTML at all. To add a comment, you use the following syntax:

/* this is a comment */

createErrorMsg

9:06 pm on Nov 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But /* Comment Tags */ are okay, aren't they?

Yes.

faster and more informative ... encyclo wins ;)