...

View Full Version : Background images and path issues



bcarl314
03-07-2005, 03:53 PM
I just found out something interesting today at work, and I want to know if it's just a funky local system configuration, or if this is indeed true.

I've got a web page (lets say index.html) with a css file attched like so:



<link href="/css/path/to/css/main.css" type="text/css" rel="stylesheet" />


Then, within my css I have several background images...



#someID {
background-image:url("/path/to/image/image.gif");
}


The thing I noticed is in the <link> tag, the root is the document root (i.e http://www.example.org/) but in the css declarations, the root is the directory that contains the css (in this case http://www.example.org/css/path/to/css/). This seems quite odd to me as I would expect "/" to ALWAYS go to the true document root. Anyone else experience this or am I going crazy?

ronaldb66
03-07-2005, 04:54 PM
According to this description (http://www.webreference.com/html/tutorial2/3.html), the leading slash refers not to the document root but to the "base URL" (which is explained as well); since relative url(...) property values in stylesheets indeed start at the location the stylesheet is at, the behaviour you described would be correct.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum