Specifying Font and Size in HTML table

Neil Weicher picture Neil Weicher · Dec 28, 2016 · Viewed 209.3k times · Source

I am trying to specify the Font Face and Size for text in a table. It seems to respect the FACE= but ignores the SIZE=. For example, I have the HTML shown below. It correctly displays the text in Courier New, but both tables display with the same font size. Any clue what I am doing wrong?

<font face="Courier New" size="12"><table width="100%"><tr><td><b>Client</b></td><td><b>InstanceName</b></td><td><b>dbname</b></td><td><b>Filename</b></td><td><b>KeyName</b></td><td><b>Rotation</b></td><td><b>Path</b></td></tr>
<tr><td>NEWDEV6</td><td>EXPRESS2012</td><td>master</td><td>master.mdf</td><td>test_key_16</td><td>0</td><td>d:\Program&nbsp;Files\Microsoft&nbsp;SQL&nbsp;Server\MSSQL11.EXPRESS2012\MSSQL\DATA\master.mdf</td></tr>
</table></font>
<font face="Courier New" size="24"><table width="100%"><tr><td><b>Client</b></td><td><b>InstanceName</b></td><td><b>dbname</b></td><td><b>Filename</b></td><td><b>KeyName</b></td><td><b>Rotation</b></td><td><b>Path</b></td></tr>
<tr><td>NEWDEV6</td><td>EXPRESS2012</td><td>master</td><td>master.mdf</td><td>test_key_16</td><td>0</td><td>d:\Program&nbsp;Files\Microsoft&nbsp;SQL&nbsp;Server\MSSQL11.EXPRESS2012\MSSQL\DATA\master.mdf</td></tr>
</table></font>

Answer

LexH picture LexH · Dec 28, 2016

First, try omitting the quotes from 12 and 24. Worth a shot.

Second, it's better to do this in CSS. See also http://www.w3schools.com/css/css_font.asp . Here is an inline style for a table tag:

<table style='font-family:"Courier New", Courier, monospace; font-size:80%' ...>...</table>

Better still, use an external style sheet or a style tag near the top of your HTML document. See also http://www.w3schools.com/css/css_howto.asp .