I've noticed this for a while but is there a reason why CSS styles don't work in while(); loops.

I've noticed this for a while but is there a reason why CSS styles don't work in while(); loops.
CSS are rules for how things should look on a page.
It is not a scripting language such as Javascript, so does not feature while / for statements.
Sorry, I should of been more clear, I'm doing outputting data from a mysql_query using mysql_fetch_assoc(); but when I use a while loop the font-size returns to it's default size and font-family.
There shouldn't be any styling issues caused by using any loop in PHP. I assume the issue is caused because the data you are outputting is presented in a table, which tend to ignore some parent CSS rules.
Try adding ",td,th" to the end of your CSS selector which determines text size, eg:
becomes:Code:body { font-size:12px; }
Of course, any other properties in that original selector would then apply to each table cell, so you'll probably want to set the font-size property by itself.Code:body,td,th { font-size:12px; }
Last edited by Apolva; 17-08-2011 at 03:06 PM.
^ I tried that but I'll try again after school, it is in face inside a table.
Want to hide these adverts? Register an account for free!