Click to See Complete Forum and Search --> : Using CSS in PHP


Smilodon
01-13-2005, 04:52 PM
Hey!

There's probably an easy answer to this, but I can't seem to find it. I'm using PHP to display a list of articles from a database in a bibliographical form, and trying to use CSS to format them. I want the first line of each entry/paragraph to span the width of the page, but each successive line in the entry/paragraph to be indented. My CSS code is:

p.citation{ margin-left:20; text-indent:-20 }

and I call it with <p class="citation">. This works beautifully for all my plain HTML pages, but not my PHP pages. Do I need to do anything special in my PHP code to get the styles to work?

Oddly enough, other styles work just fine (table widths and HR widths, for example). Just not the paragraph one. I'd think my code was wonky, except that it works on HTML pages just fine.

Well, any help would be appreciated! Thanks!

NogDog
01-13-2005, 05:00 PM
PHP will have no impact on how your browser interprets CSS and HTML. Most likely some subtle difference is slipping into the text you are outputting that defines your CSS. In other words, if you point you browser to your PHP page, do a View Source, and copy that source into an HTML file; when you view that new HTML file it will look just like the PHP file did.

If you haven't yet, try using the w3.org validators on your PHP pages and see what they have to say:

http://jigsaw.w3.org/css-validator/

http://validator.w3.org/

Smilodon
01-13-2005, 05:11 PM
Hoorah!

I validated my HTML, and it was fine, so I validated my CSS, and it wasn't. I'd left off units on my margin and indent lengths. I added those, and all works perfectly now. I don't know why it worked on my HTML pages but not my PHP pages, though. Oh, well.

Thanks!

Matt :)