11 replies [Last post]
Anonymous
Anonymous's picture
Guru
calgary,alberta
calgary,alberta

Howdy all, I am putting together a site that uses php to build the front page. I really want to control the text style of this site with CSS, but seem to be running into some very odd problems with it.

When I produce mysql queries with php, my CSS sheet will only apply certain text adjustments to the results! For example, my CSS will format my text as verdana, but not adjust it to the 11pt font size I have set. What is even more strange is that on the exact same page, I have a php script which will obey the CSS 11pt font size, but NOT the verdana font type! How strange... If anyone can post some advice on how to use CSS with PHP, I would be very much obliged! Thanks for your time.

DJSdotcom
Offline
Enthusiast
Rochester, NY / Chicago, IL
Last seen: 17 years 44 weeks ago
Rochester, NY / Chicago, IL
Joined: 2003-03-23
Posts: 95
Points: 0

Wrestling PHP into working with CSS

Ryyo,

I use PHP pretty extensively when building websites, could you post the PHP code that you're using? If it includes passwords or sensitive directory names, make sure to change those hehe Wink

-Mike

</twocents>

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 4 years 52 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

Wrestling PHP into working with CSS

That makes two of us...

Don't forget of course the SQL query should do nothing to the site, it's how you print/echo the results that matters. Like Mike said, let's have a look at either the PHP or the HTML output and we can solve this!

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

Anonymous
Anonymous's picture
Guru

Wrestling PHP into working with CSS

Excellent! Here is the php that I am using:

Quote:

print "
<table width=500 border=0 cellpadding=5 cellspacing=0>
<tr>
<td width=50 height=50 valign=middle><div align=center></div></td>
<td valign=middle>$author
$DateTime</td>
</tr>
<tr>
<td>&</td>
<td background='images/blog_body_bckgrnd.gif'>Entry: $message</td>
</tr>
</table>
<table width=500 border=0 cellpadding=5 cellspacing=0>
<tr>
<td>&</td>
<td>&</td>
</tr>
</table>"

;} //close while loop

?>

The external style sheet that my site calls up in as follows:

Quote:
body {font-size: 8pt; font-family: verdana}
A:link, A:visited {color:#FF6600; text-decoration:none}
A:hover {color: black}

I am pretty sure this issue has something to do with the and <p> tags, as my php displays in the correct font, just not the right size! I'd appreciate any insights you may have, thanks for your time!

Ryyo

Ryyo
Offline
Regular
East Lansing MI
Last seen: 17 years 41 weeks ago
East Lansing MI
Joined: 2003-04-16
Posts: 13
Points: 0

Wrestling PHP into working with CSS

Sorry, the above post is sort of messed up, as I forgot to disable HTML markup. Let me try again:

Quote:
print "
<table width=500 border=0 cellpadding=5 cellspacing=0>
<tr>
<td width=50 height=50 valign=middle><div align=center><img src=$topic_image_display></div></td>
<td valign=middle><b>$author</b><br>$DateTime</td>
</tr>
<tr>
<td>&</td>
<td background='images/blog_body_bckgrnd.gif'><b>Entry: </b>$message</td>
</tr>
</table>
<table width=500 border=0 cellpadding=5 cellspacing=0>
<tr>
<td>&</td>
<td><b>&</td>
</tr>
</table>"

;} //close while loop

?>

And my CSS looks like this:

Quote:
body {font-size: 8pt; font-family: verdana}
A:link, A:visited {color:#FF6600; text-decoration:none}
A:hover {color: black}

I think this is an issue with the <body> and <p> tags, as the PHP does set the font name correctly.

I wish I had registered before that first reply... Oh well

:roll:

Ryyo

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 day 20 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

Wrestling PHP into working with CSS

Hi Ryyo,
Your problem is nothing to do with PHP, The best way to check this is to view the source of the page so you see it how the browser sees it.
Then work from there.

Although tables are contained in the body tags, they have there own default style properties, in this case font-size, which override the properties set for body.

What you need to do is assign the same font properties that you use for body to tables.
body, table, table td {font-size: 8pt; font-family: verdana} That should take care of most cases.

Anonymous
Anonymous's picture
Guru

Wrestling PHP into working with CSS

Oh wow Tony, thanks so much: that did the trick!

I am quite new to CSS, and this forums seems like a great place to get help. Do you have any reccomendations for online tutorials that cover CSS?

I really like the flexibility that CSS provides, it really expands HTML's possibilities!

-Ryyo

Sven
Sven's picture
Offline
Enthusiast
Brisbane, Australia
Last seen: 13 years 33 weeks ago
Brisbane, Australia
Timezone: GMT+10
Joined: 2003-03-12
Posts: 166
Points: 0

Wrestling PHP into working with CSS

There's a list of useful sites on CSS contained in this thread: [url]http://www.csscreator.com/css-node/2url]

Deanimal
Offline
Regular
Last seen: 17 years 41 weeks ago
Timezone: GMT-4
Joined: 2003-04-16
Posts: 17
Points: 0

Wrestling PHP into working with CSS

This problem with font-size not inheriting from body into tables caused me similar trouble. Except I was using relative sizes (ems) so it really got strange. The solution I came up with is a little different -- I don't know if it's the best, but it works so far.

I don't set font-size in body; I set it only in p, li, dt, dd, pre. Then, I always make sure any text is inside one of those tags. So, inside a table cell <td> there are paragraph tags <p>.

If there's a special class for say, links, I'll set the size for that class so it won't need <p> tags too.

p, li, dt, dd, pre {font-size: 0.9em;}
div#menu a {
    display: block;
    font-size: 0.84em;
    }

Dean

Anonymous
Anonymous's picture
Guru

Wrestling PHP into working with CSS

I'm using pixel font sizes, and orienting my CSS like this has solved all my problems:

body, table, table td {font-size: 11px; font-family: verdana}

Nice to know!

-Ryyo

nexia
nexia's picture
Offline
Regular
Last seen: 17 years 44 weeks ago
Timezone: GMT-5
Joined: 2003-03-22
Posts: 42
Points: 0

Wrestling PHP into working with CSS

the only problem with font size is that we always think it look cool on our browser so it will look good for everyone.

point is that IE is doing 10px bigger than Opera is doing the same 10px ... even the other .em sized fonts...

the best is always to think about these differences... if you have some text that is fitting in your display, always make the display a pixel or two bigger, so you always will be fitting even if the browser is not using the font correctly.

and remember... tables, body, th, etc... all the tags that build elements are using their own style... using a global style in the body will change nothing to the others (or at least the background color if you use none)

tags that are modelling the content, like div, span, h1, etc, are using the default settings of your browsers... and are not likely to be exactly the same on any browser... H1 is twice the size in IE compared to Netscape... so it's better for you to make them a default in your CSS or making different styles for each element of your page, so you can apply a class/id for each...

nexialism source of all knowledges

TylerNZ
Offline
newbie
Last seen: 14 years 14 weeks ago
Joined: 2003-11-11
Posts: 1
Points: 0

what if you have specific

hi I seem to have this same issue, except I have seperate classes for each aspect of my page ... so I can't just set a class for my <p> etc.

My class (stafftitles) show's the color, background, border etc ... but doesn't show the font boldness.

Any suggestions, or documentation on PHP & CSS?

Thanks!