...

View Full Version : link rel for css



titaniumbean
08-23-2005, 04:29 PM
Hey I have a question regarding folder structure and linking to css files.

My folder layout is like so:

Site> Home, css, index.html

:- css> main.css
:- home>products.html


In my products file I want to link to the main css file which is one level up then one level down in a different folder. is there a way of linking it quicker than http://www... etc etc


titaniumbean.

Tristan Gray
08-23-2005, 04:31 PM
I believe simply 'site/whatever/main.css' will do the trick.

titaniumbean
08-23-2005, 04:37 PM
That doesn't seem to be working i'll just put the http. no matter.



titaniumbean.

mark87
08-23-2005, 05:51 PM
Have you tried something like

"../otherfolder/cssfile.css"

?

Bill Posters
08-23-2005, 06:01 PM
Starting a src, href or css url with / is like starting it with http://www.yourdomain.com/

e.g.


href="/home.html"

…is the same as…

href="http://www.yourdomain.com/home.html"



src="/images/myimage.jpg"

…is the same as…

src="http://www.mydomain.com/images/myimage.jpg"



background-image: url(/images/myimage.jpg)

…is the same as…

background-image: url(http://www.mydomain.com/images/myimage.jpg)

mrruben5
08-23-2005, 06:04 PM
Browsers read a css file with url's to bg images relative to the location of the stylesheet. Let's say you have a dir with index.htm, and 2 folders, called images and css, when you link to the css file (css/style.css), In that css file the a background could be called like this: body {background: url(../images/body.gif)}

You don't need a slash to indicate the root of your site.

Bill Posters
08-23-2005, 06:59 PM
Browsers read a css file with url's to bg images relative to the location of the stylesheet. Let's say you have a dir with index.htm, and 2 folders, called images and css, when you link to the css file (css/style.css), In that css file the a background could be called like this: body {background: url(../images/body.gif)}

You don't need a slash to indicate the root of your site.

I'd say it's preferable to use the root slash (whether you're in the markup or the css) and walk forward through any directories, rather than step backwards.
Using the root, you don't have to worry where you are in relation to another directory as you're starting from root every time. It's a more simple and clean approach.
It also helps standardise your use of href/src/url values throughout the site, which is a good thing, imho.

Tristan Gray
08-23-2005, 07:17 PM
I second that notion... with a vengence!

titaniumbean
08-24-2005, 10:23 AM
Starting a src, href or css url with / is like starting it with http://www.yourdomain.com/

e.g.


href="/home.html"

…is the same as…

href="http://www.yourdomain.com/home.html"



src="/images/myimage.jpg"

…is the same as…

src="http://www.mydomain.com/images/myimage.jpg"



background-image: url(/images/myimage.jpg)

…is the same as…

background-image: url(http://www.mydomain.com/images/myimage.jpg)



Awesome cheers. :thumbsup: :D :) ;)




titaniumbean. :cool:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum