sunleo
sunleo

Reputation: 10943

Include CSS file or CSS Style in HTML

If I use css code directly inside of the html code it works.If I use by linking css file inside of the html by tag it is not working.But I tried with ffox viewsource and link for css redirects to the perfect CSS.Please enlight me in this Case.Thanks in Advance.

CSS(POStyle.css) File included like this in HTML :

 <link href="$contextpath/css/yes/POStyle.css" rel="stylesheet" type="text/css"></link>

POStyle.css has

.popupCSS td, .popupCSS td
    {
         border:1px solid black;
         background-color:#EAF2FB;
         color : red;
    }

CSS inside the html directly :

<style type="text/css">
.popupCSS td, .popupCSS td
    {
         border:1px solid black;
         background-color:#EAF2FB;
         color : red;
    }   
</style>    

Upvotes: 2

Views: 214

Answers (2)

Karthick Kumar
Karthick Kumar

Reputation: 2361

Use {$contextpath} instead of $contextpath. It is a smarty variable.

Upvotes: 0

Kevin Bowersox
Kevin Bowersox

Reputation: 94469

When using:

<link href="$contextpath/css/yes/POStyle.css" rel="stylesheet" type="text/css"></link>

The browser uses the string literal $contextpath/css/yes/POStyle.css to request the CSS file. There is no replacement that occurs as you would expect in JSP files or some other view technology.

You must use either an absolute or relative url to the file:

Relative

<link href="../css/yes/POStyle.css" rel="stylesheet" type="text/css"></link>

Absolute

<link href="http:/www.mydomain.com/context/css/yes/POStyle.css" rel="stylesheet" type="text/css"></link>

Upvotes: 1

Related Questions