1

I am using a external css for my CGI web form but I can't get the .css to take to the page. Is there a certain way a external css needs to be called. I tried:

<link rel="stylesheet" type="text/css" href="../styles/archiveRequest.css" media="screen" />

which has not been working. I have tried moving the css in the same folder as the .cgi with still no results.

3
  • All looks well with that declaration, I imagine you just have it pointing at a wrong directory. Commented Feb 14, 2011 at 18:34
  • As mentioned below, if styles is at the top level, just lose the ".." Commented Feb 14, 2011 at 23:49
  • The directory is not the problem. Commented Feb 15, 2011 at 16:15

3 Answers 3

3

The href attribute needs to be in relation to the page you're viewing in your browser. For example, if your URL is http://www.example.com/cgi-bin/mypage.cgi then, with your above code, your CSS file needs to be viewable in a browser at http://www.example.com/styles/archiveRequest.css. Try loading it up directly in your browser using the direct URL. Also take a look at your server logs, and you'll probably find 404 errors showing where the file is trying to be loaded from.

Sign up to request clarification or add additional context in comments.

2 Comments

I was able to load the /styles/archiveRequest.css page in my browser.
@James: Then there's some other problem. Look at your requests in Firebug or Chrome's developer mode. Look at your server logs. Those will shed light on your problem.
0

If you were "able to load the /styles/archiveRequest.css", then use "/styles/archiveRequest.css" as href too.

2 Comments

That is exactly what my problem is. I do use that as my href and it still does not work.
@james: and if you use it as URL?
0

I know this was asked quite a while ago, but I had the same problem today and spent hours looking for an answer. This is what worked for me:

If my cgi script is /var/cgi-bin/test.cgi, putting my style.css file in the same directory did not work. Apparently this makes it get treated like a script, which it isn't. I moved my style file to /var/www/styles/style.css and made it non-executable (but readable).

In a browser, I was able to see it at localhost/styles/style.css, so in my cgi script I referenced it as:

my $stylesheet = "/styles/style.css"; start_html(-style=>{'src'=>$stylesheet}), ....

Hope this is useful to someone else.

(The answer that helped me was found here: http://forums.devnetwork.net/viewtopic.php?f=1&t=113842)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.