php cannot see my html css

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
elduke
Forum Newbie
Posts: 2
Joined: Sat May 16, 2009 7:23 pm

php cannot see my html css

Post by elduke »

I would like to echo the following giving it a CSS style:
echo '<p class="mypstyle">this is a test</p>';

but the output is plain text without any style.
Now if i was to break out of php instead and in the same location and enter:
<p class="mypstyle">this is a test</p>

then the output is styled correctly.
So my question is why doesnt php see my css?

The only way i've gotten the echo to output the above html correctly is if i include this in my php file:
echo '<head><style type="text/css">' . include('mycss.css') . '</style></head>';

Is this my only option?... any help would be greatly appreciated...
ldougherty
Forum Contributor
Posts: 103
Joined: Sun May 03, 2009 11:39 am

Re: php cannot see my html css

Post by ldougherty »

If you're not including that css file like you said then how is your tag being defined at all?

You could just show the CSS in the HEAD tag before your open <?php tag

You should still be able to reference any tags you use by PHP. As long as the CSS is defined in the document then you should be able to reference it via PHP without issue.
elduke
Forum Newbie
Posts: 2
Joined: Sat May 16, 2009 7:23 pm

Re: php cannot see my html css

Post by elduke »

ok problem solved.. thanks...

there was an error in my php somewhere before the echo- putting the include again above the echo was resolving the problem- and confusing me. i fix the error and then remove the second include. everything ok now.
Post Reply