Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External CSS

Status
Not open for further replies.

slanza

Technical User
Jul 21, 2001
7
US
Hi,
Can someone help with the following?
I am trying to link to an external style sheet, but my styles are not taking affect in my browser. If I add the styles directly to the page it works, but when I remove the local styles and add the external link it does not. I have used css before with no problems, but this is the first time I am trying to add styles to a ColdFusion page. Does that make a difference?

This is my link:
<link rel=stylesheet href=&quot;style.css&quot; type=&quot;text/css&quot;>

This is my style on the page:
<span class=&quot;twelve&quot;>Enter Search Word:</span>

Please help!! I am totally baffled.
Thanks,
Steve
 
A couple of suggestions ...

Put double quotes round stylesheet in the link:
<link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot;>

Make sure the twelve style is defined in your external stylesheet

Make sure the path to the external sheet is correct in the href parameter on the link.

Greg.
 
Steve,

make sure that the link is included in your page, if necessary put your html code within <cfoutput>tags.
Check this by viewing your source code.

Check if the css file is in the same directory as the html file.

try to create a html file with a reference to the css file and see if this works, if not your css file is not correct.

Erwin
 
Thanks,
I tried everything you have suggested. I did try the stylesheet with and without &quot;.

<link rel=&quot;stylesheet&quot; href=&quot;newstyle.css&quot; type=&quot;text/css&quot;>

This is my stylesheet:

.twelve { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #000000}

I saved the file as test.html and the styles worked. Is there something that I have to set in my ColdFusion server for css to work?

Steve
 
Steve,
have you had a look at the produced html from the coldfusion page? Is the link there correct. There is nothing to be set as far as I'm aware that turns css on and off. maybe you need to include some code so we can look over it, maybe just a blind spot and you can't see the error anymore from looking at it so often.
Erwin
 
Here is my code. Sorry for the long post, I just don't want to miss anyhthing.


<CFQUERY DATASOURCE=&quot;WTP&quot; NAME=&quot;MathCategories&quot;>
SELECT Category
FROM MathCategories
ORDER BY Category
</CFQUERY>

<cfif IsDefined (&quot;URL.Category&quot;)>
<CFQUERY DATASOURCE=&quot;WTP&quot; NAME=&quot;highlight&quot;>
SELECT Category
FROM MathCategories
WHERE Category = '#URL.Category#'
</CFQUERY>
</cfif>

<CFQUERY DATASOURCE=&quot;WTP&quot; NAME=&quot;MathTerms&quot;>
SELECT Term, Definition, TermID
FROM MathTerms
<cfif IsDefined (&quot;URL.Category&quot;)>
WHERE Term LIKE '#URL.Category#%'
</cfif>
<cfif IsDefined (&quot;form.Term&quot;)>
WHERE Term LIKE '#Term#%'
</cfif>
ORDER BY Term
</CFQUERY>

<HTML>

<HEAD>
<TITLE>Math Dictionary</TITLE>
<link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot;>
</HEAD>

<BODY bgcolor=&quot;#FFFFFF&quot;>


<table width=&quot;440&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot;>
<tr>
<td><span class=&quot;twelve&quot;>Math Dictionary</span>
<FORM ACTION=&quot;index.cfm&quot; METHOD=&quot;POST&quot;>
<span class=&quot;twelve&quot;>Enter Search Word:</span><BR>
<INPUT TYPE=&quot;text&quot; NAME=&quot;Term&quot;><INPUT TYPE=&quot;submit&quot; VALUE=&quot;Search&quot;>
</FORM>

<P>
<cfoutput query=&quot;MathCategories&quot;>
<cfif IsDefined (&quot;URL.Category&quot;)>
<cfif highlight.Category EQ &quot;#Category#&quot;>
#Category#&nbsp;
<cfelse>
<a href=&quot;index.cfm?Category=#Category#&quot;>#Category#</a>&nbsp;
</cfif>
<cfelse>
<a href=&quot;index.cfm?Category=#Category#&quot;>#Category#</a>&nbsp;
</cfif>
</cfoutput>
</P>

<hr width=&quot;430&quot; align=&quot;left&quot; noshade size=&quot;1&quot;>

<cfif (IsDefined (&quot;URL.Category&quot;)) OR (IsDefined (&quot;form.Term&quot;))>

<cfoutput>
Found #MathTerms.RecordCount# Term<cfif MathTerms.RecordCount IS NOT 1>s</cfif>
</cfoutput>

<cfoutput query=&quot;MathTerms&quot;>
<P>
#Term#<br>
#Definition#
</P>
</cfoutput>

<hr width=&quot;430&quot; align=&quot;left&quot; noshade size=&quot;1&quot;>

<P>
<cfoutput query=&quot;MathCategories&quot;>
<cfif IsDefined (&quot;URL.Category&quot;)>
<cfif highlight.Category EQ &quot;#Category#&quot;>
#Category#&nbsp;
<cfelse>
<a href=&quot;index.cfm?Category=#Category#&quot;>#Category#</a>&nbsp;
</cfif>
<cfelse>
<a href=&quot;index.cfm?Category=#Category#&quot;>#Category#</a>&nbsp;
</cfif>
</cfoutput>
</P>

</cfif>

</td>
</tr>
</table>

</BODY>
</HTML>
 
By the way, I did check the source code in the browser for the .cfm file and the link to the style sheet is there.
 
Steve,
I can't see anything wrong with the code. Are you using cfstudio? If so, have you tried dragging the stylesheet into the file? This should calculate the path for you, see if this is different.
Can't think of anything else at the moment. :-(
Erwin
 
Thanks for the suggestions.

I do use Studio to write the CF code, but I have been using Dreamweaver to apply styles. I took out all styles and links and then opened the file in Studio and dragged the style.css to the document. It added the same link as before (My style.css file is in the same directory as the .cfm file).

In Dreamweaver, I can see the styles listed in the styles windows, and when I apply a style to a selection, I can see the style take affect in the Dreamweaver window. But when I load the page in the browser, the styles are gone.

I can't understand this. If I take the exact same code and call the page .html, the styles work, but then of course the coldfusion code does not. Hmmmm
 
Do you have <style> tags in your external file? If so remove them...

You may want to post the code to the external css file, the problem could be in it.
 
Sorry. I feel so stupid. It turns out it was the Web Server settings. I tried the page in Netscape and I received errors having to do with reading the newstyle.css file. I then checked the PWS folder properties and realized that the &quot;read&quot; option was not checked. I was not aware that this was required of CSS. I have now checked all three options &quot;Read&quot;, &quot;Execute&quot; and &quot;Scripts&quot;.
Thanks again for all the help. :)
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top