PDA

For continued disscussion on this topic : External Style Sheets



lfc1
06-30-2000, 03:15 PM
Hi
i am trying to link to an external style sheet which contains the layout (background image, link, general design)but when i preview my site the background image and other stuff in the external style sheet does not load, am i doing something wrong?

Thanks in advance

Vincent Puglia
06-30-2000, 03:23 PM
Hi,

That depends. How are you linking? In other words, can we see some code? Also, when you say image & link, you don't mean javascript code, right?

Vinny

gzazJim
06-30-2000, 04:53 PM
Ifc1, welcome.

I am assuming you wish to link to an external style sheet placed on your server? If this is the case, format is as follows:

<head><link rel=stylesheet type="text/css" href="filelocation/filename.css"></head>

The above assumes your Cascading Stylesheet is saved as a plain text file with .css as the extension... If you are linking to a StyleSheet at another location...

<style type="text/css">
@import url(filename);
.
.
.
</style>

Caveat Alert!: I THINK the above (@import) only works with IE 4/5 - not sure if it works with newer versions of NN...

Hope this helps to answer your question!

Good Luck,

Jim

[Edited by gzazJim on 06-30-2000 at 10:55 AM]

lfc1
06-30-2000, 06:17 PM
<head><link rel=stylesheet type="text/css" href="filelocation/filename.css"></head>

this is the link i was using, but nothing was coming up, i think i have misinterpretted what this can do, am i able to have buttons linked to other sites in the external style sheet so that if i was to add another button i could just add it to the style sheet instead of adding the button to each page (time consuming)

The image and link bit - i mean have all my links (not the style that makes the link underline, overline etc but the actual link to another part of the site)in the style sheet, so as with the buttons adding a new link would not be time consuming

I am trying to view it offline first (its not uploaded so if i link the position on my hard drive will it still come up)

Thanks again

caislander
06-30-2000, 06:50 PM
Hi,

I could be wrong on this one, my knowledge of style sheets isn't what it should be :( , but I don't think you can do all of that with a style sheet. I know some of it can be accomplished (button & maybe links) with an external javascript (Vinny or others can help you with that). Style sheets are used to control style/placement of text elements within a site to maximize consistencey of the site and minimize work, to my knowledge they have minimal utilization in the use of images and link besides controlling the appearance/placement.. Maybe some else has more info. Anybody??

Vincent Puglia
06-30-2000, 07:50 PM
Hi lfc1,

As caislanders believes, it is so. :)
*.css files can only contain style information; *.js files can only contain javascript information -- and ne'er shall the twain meet.
The *.js include:

<script language='javascript' src='someName.js'></script>

The content:
javascript only -- no html tags of any sort (including <script>s) -- declarations (var myVar; ), assignments (myVar = 10; ), functions (function doNothing() { ; } ), comments (// this is a 1-line javascript comment) (/* this is a multi-line javascript comment */), etc.
If you want to include html within the *.js file it will have to be as a variable or part of a javascript command, for example:

document.write("<html><head>.....");
var myLinks = new Array();
myLinks[0] = "http://www.javascriptcity.com";
myLinks[1] = "http://members.aol.com/grassblad";
pic1.src = "images/pic1.gif";

Once included in the html file, you can use the variables as if they were physically within the file. For an example, see the "Reading Banner Data from a File" script (or somesuch) at my site.


Hi gzazJim,

Your fears are well-found @import (along with stylesheet[x]) is IE-specific. Don't know about NN6; haven't downloaded it yet, but I suspect they cover it.

Vinny

lfc1
06-30-2000, 08:17 PM
Thanks alot, you have been extremely helpful.
I had a suspicion that my ideas about the external style sheets were wrong.

Could u point me in the direction of some good javascript tutorials

Thanks again

Vincent Puglia
06-30-2000, 08:43 PM
Hi,

You could check out:
1) the ones here (javascript city link at the bottom)
2) the javascript primer 30+ lessons/pages http://www.htmlgoodies.com

Vinny

lfc1
06-30-2000, 09:38 PM
thanks