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

    Thread moved to ClientSide Technologies forum (since this doesn't pertain to PHP).

      When it comes to HTMl code, ALWAYS validate it.

      The font element has been deprecated for a long long time. Do not use it. And I do believe the validator would tell you this. Even if it doesn't complain about it being deprecated, I have a strong feeling the font element does not allow block or table elements, which means a browser is likely to turn your invalid html code into something else, such as

      <font ...>
      <-- the closing font tag would be inserted before the table !-->
      </font>
      <table>
      
      <-- since there no longer is a matching opening font tag, the closing font tag is disregarded !-->
      </table>
      

      But since font is deprecated, I do not use it and can't say for sure what elements it did and did not allow. Still, I do find this to be very likely from your description of what happens.

      And apart from that, your table is lacking thead and/or tbody element(s), which in turn would be lacking tr element(s), which in turn would be lacking th and or td element(s). Which the validator should also tell you.

      What you should do is use css and/or inline styles

      <style type="text/css">
      th {
      font-size: 18px;
      font-family: Arial;
      }
      // class can be use to add to or override the above
      .red {
      color: red;
      }
      </style>
      </head>
      <body>
      <table>
      <thead><tr>
      <th>This uses the style set for th. i.e. 18px Arial</th>
      <th class="red">This text is 18px Arial in red color</th>
      </tr></thead>
      <tbody>
      <tr>
      <td>This is whatever is default in your browser unless you specify something for table, tbody, tr which is inherited by td, or directly specify something for td.
      </td>
      <td class="red">This is the same as the above, but red.</td>
      </tr>
      </table>
      </body>
      </html>
      
        Write a Reply...