Jump to content

add code for font size under php echo code

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
Good day!

I have a pure php code, so my table was in echo and I want to change the font and font-size of text in table header but when I put thid code:

echo "<font size="18" face='Arial'>";

echo "<table>";


and at the lower part i close it

echo "</table>";

echo "</font>";



It only take effect in the text outside the table. and when I try to put it on the <table> It doesn't take effect.

Thank you in advance

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
You need to either apply the font tags within each <td>, or apply a CSS attribute to the tag which would look something like this:
td {
    font-size:18px;
    font-family:Arial;
}
Of course you can add a class to the <td> such as class="size18td" and apply it with ".size18td {" instead of "td {" in the CSS.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
DEViANT

DEViANT

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 358 posts
This should do it. CSS Attributes


echo '<div style="font-size: 18pt; font-face: Arial;">';

and at the lower part i close it

echo '</table>';

echo '</div>';  


However, a better way of doing this would be to declare CSS classes and assing the <td> tags to the class as such :


.myclass {

 font-size: 18pt;

 font-face: Arial;

}



echo '<table name="mytable" cellpadding="2" cellspacing="0" border="0"><tr valign="top"><td class="myclass">Some Text</td></tr></table>';


Also, please notice that I use combination of single and double quotations to avoid having to escape them. For example instead of doing this :

echo "<table name=\"myname\">";


Its easier to do this :

echo '<table name="myname">';


:D You should rep+ me so that I can win :D

My Blog | Ask me!
Error : Satan did it