RealDrift Posted August 2, 2009 Share Posted August 2, 2009 Hi, I want to echo the following but want the font to adhere to the css rules I have defined in a file called in.css Here is the echo: echo "<span class=\"output.reward\">You Donated!</span>"; Before this echo I put the following line to include the css file: echo "<link rel=stylesheet href=includes/in.css type=text/css>"; the css thing is called output.reward and is in the in.css file like so: output.reward { font-size: 10px; font-family: Verdana; color: #FFCC00; } The problem is the echoed font is not what the css rule is defined as. Any help would be good. Thanks Quote Link to comment Share on other sites More sharing options...
gevans Posted August 2, 2009 Share Posted August 2, 2009 The style sheet has to be between the head tags of your page... <html> <head> <?php echo '<link rel="stylesheet" href="includes/in.css" type="text/css" />'; ?> </head> <body> <?php echo '<span class="reward">You Donated!</span>'; ?> </body </html> Also you may have noticed that I changed the class name, a class name can't have a period in it... Also to let the css file know you're using it as a class (rather than an element, or id) it needs a period at the start as follows: .reward { font-size: 10px; font-family: Verdana; color: #FFCC00; } Quote Link to comment Share on other sites More sharing options...
RealDrift Posted August 2, 2009 Author Share Posted August 2, 2009 Thanks for the quick reply, I gotta go to bed now - its 2:46am here and i gotta get an early start lol I'll test your method tommorow. I wanted to know if everytime I want to use css font rules in a php echo I have to put them in <body> tags and such? or is there another simpler way? Thanks Quote Link to comment Share on other sites More sharing options...
gevans Posted August 2, 2009 Share Posted August 2, 2009 I'm not sure I fully understand your question. You should assign class names wherever appropriate in your html, include the html outputted from php. Quote Link to comment Share on other sites More sharing options...
RealDrift Posted August 6, 2009 Author Share Posted August 6, 2009 I have done as you suggested but the echoed sentence is still not what the css says it should be. Quote Link to comment Share on other sites More sharing options...
watsmyname Posted August 6, 2009 Share Posted August 6, 2009 I have done as you suggested but the echoed sentence is still not what the css says it should be. make sure your in.css is in includes folder. if still not working try to use inline style. like echo "<span style='font-family:Verdana, Geneva, sans-serif;font-size:10px;color:#ffcc00'>You Donated!</span>"; Quote Link to comment Share on other sites More sharing options...
RealDrift Posted August 6, 2009 Author Share Posted August 6, 2009 the in.css is in the correct folder and surprisingly enough the inline style doesn't work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.