php and style sheets – PHP

  php

Q(Question):

Not sure if this is the right section to be posting to but anyway,

I was wondering if you have a php script within a html page and on that html page you have a link .css file, can that .css have an effect on tags that are echo within the php script.

For example if you had some formatting for a paragraph tag (e.g. defined the font-family) would it effect this

[PHP]echo "<p> This is some text </p>";[/PHP]

Any help is welcome thanks

A(Answer):

Not to worry i figured out myself, the only reason i asked was becuase i was having some strange outcomes when applying the stylesheet to a php document that shouln’t have happened lol.

Thanks anyways

A(Answer):

Not sure if this is the right section to be posting to but anyway,

I was wondering if you have a php script within a html page and on that html page you have a link .css file, can that .css have an effect on tags that are echo within the php script.

For example if you had some formatting for a paragraph tag (e.g. defined the font-family) would it effect this

[PHP]echo "<p> This is some text </p>";[/PHP]

Any help is welcome thanks

Yes, of course it would. PHP outputs HTML the same, so the styles will still be applied.

But I see you answered yourself now. 😛

A(Answer):

Yep. The key thing to remember is that PHP is executed server-side, only returning it’s output to the client, which is then used by the client just as any normal HTML / CSS /JavaScript or whatever else client-side content would be used.

A(Answer):

for example


echo "<font color='#000000' size='Arial'> this is sample text</font>"

hope you will clear let me know

A(Answer):

for example


echo "<font color='#000000' size='Arial'> this is sample text</font>"

hope you will clear let me know

Explain ?

A(Answer):

for example


echo "<font color='#000000' size='Arial'> this is sample text</font>"

hope you will clear let me know

First of all, your are using the <font> tag incorrectly. You put ‘Arial’ in the size attribute…

Besides that, I wouldn’t recommend using this type of markup. The <font> tag is ancient and you would be far better of replacing it with a <span> using CSS styles. They give you a lot more options than the <font> tag.

For example, to replace the tag you posted (without the bug), I could do this:


<span style="color: #000; font-family: Arial; size: 12pt;">
This is sample text
</span>

And you have the option of adding CSS styles and even moving the styles out of the markup entirely.

LEAVE A COMMENT