Welcome to WebmasterWorld Guest from 174.129.127.214

Forum Moderators: not2easy

Message Too Old, No Replies

Cannot Find StyleSheet

When linking from another page

   
12:08 am on Jun 23, 2010 (gmt 0)

5+ Year Member



When I type in the url directly, the stylesheet is found and the page shows correctly. But if I click on a link from another page of the website to the same url I typed-in, it isn't finding the stylesheet and the page isn't showing correctly. What could be causing this?
12:29 am on Jun 23, 2010 (gmt 0)

WebmasterWorld Senior Member



I'm assuming this is a site you are working on and making changes to then testing them so -- try clearing your cache to get the fresh version?
1:01 am on Jun 23, 2010 (gmt 0)

5+ Year Member



You assume correctly :) But still the same problem :(
2:17 am on Jun 23, 2010 (gmt 0)

WebmasterWorld Senior Member



How about this...the links you are clicking on from other pages are actual links to the live version of the site rather than the development version. Such as this...

Maybe you are working on dev server localhost/subpage.html but click on a link that is actually coded to the live site www.example.com/subpage.html so you are seeing the live version rather than the dev version -- hehehe, not that I have had that happen to me :p
2:25 pm on Jun 23, 2010 (gmt 0)



Always clear your cache and do a hard refresh (Ctrl + F5) several times to eliminate any possibility of an old cached page being the problem.

If you have used relative paths for your links, you must be sure that you are telling the browser how many directories to backup to and then down to find the file. This is only important if files are in different folders which means you have a more complex directory structure. Absolute paths to folders/files is ok, but relative paths work just fine.

Too bad they don't allow URLs to sites so we can look at the problem page(s).
7:17 pm on Jun 23, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Relative paths *work* but they always seem to bring up problems like this. If you have

/css/style.css
/modules/classes/autonomy.html
/modules/classes.html

You have to have

../../css/style.css
and
../css/style.css

respectively. Two different links for the same file. But if you use

/css/style.css

in both files, you have both consistency and ease of maintenance, no need to remember how many toothpicks get you back to home. :-) So that's the first thing, adopt this usage when uploading and many of these will go away. Down-side: it doesn't work offline, your computer is not (usually) a web server and has no document root.

O.T.: As for versioning issues ("I updated the style sheet, changes aren't showing") this is often a combination of browser specific issues and the caching settings of the server, both eliminated (well, worked around) by an old trick. Leave your stylesheet file name the same, but use a query string:

href="style.css?version1234"

Change the bolded portion every time you upload, this will trick the browser into thinking it's a new file and will always download the style sheet. Of course this is not something you'd want to do site-wide, just while making mods to specific pages, but it speeds up your development.
12:22 am on Jun 24, 2010 (gmt 0)

5+ Year Member



OK. I found the problem. I had a trailing backslash after the filename, ie: http://example.com/filename.php/. Removing the backslash solved the problem. Thanks for all your comments.

[edited by: tedster at 3:02 am (utc) on Jun 24, 2010]
[edit reason] Switched to example.com to make the URL more readable [/edit]