Unable to link css file when using HTML::Template

Rakish's Avatar, Join Date: Jul 2006
Go4Expert Member
Hi all,

I am having a hard time linking a css file to a template when using the HTML::Template Module.

Here is what i have:

1) myserver/cgi-bin folder, which has all the .pl files.
2) myserver/html folder, which has the template, CSS and html files

the template files have extension .tmpl

If i call an external CSS file like below:

Quote:
<html>

<head>

<title>CssCreator-->HTML 4.01 Strict Template</title>

<meta http-equiv="content-type" content="text.tmpl;charset=utf-8" />

<meta name="generator" content="www.csscreator.com" />

<link rel="stylesheet" href="test.css" type="text/css" />
It doesnt work,

but if i embed the same CSS code in the:


Quote:
<head>

<style>
css code
</style>

</head>
then it works fine.

I have tried my best, and i dont want to give up on it.

Please help.

Thankyou so much.

Rakesh Gupta
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Try giving <link rel="stylesheet" href="./test.css" type="text/css" /> see the "./" or even test with the absolute path and see what is going wrong and step down to the actual path that is relative to the page requesting css.
Rakish's Avatar, Join Date: Jul 2006
Go4Expert Member
thanks Shabbir,

I got a reply from another forum and now it works for me,

what you gotta do is to provide the url instead of a path (absolute or relative - both didnt work for me)

below is the code:

Quote:
<link rel="stylesheet" href="http://server/[path to the css file]" type="text/css" />
if the css file is in the /var/www/html folder and the css file is style.css

the code will look like:

Quote:
<link rel="stylesheet" href="http://server/style.css" type="text/css" />
hope it helps others

Rakesh Gupta
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Thats the way to specify the absolute URL but for relative one you can use "./" and "../" to achieve the same. You can check the source code of the current page and you will see the relative css is linked.