Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying Font and Size in HTML table

Tags:

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> 
like image 470
Neil Weicher Avatar asked Dec 28 '16 18:12

Neil Weicher


People also ask

How do you change the font-size in a table in HTML?

To change the font size in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-size. HTML5 do not support the <font> tag, so the CSS style is used to add font size.

How do you style text in a table in HTML?

To style the text within a table, you use the same CSS properties that you would use in styling any text. The thing to remember is that, you need to know which HTML element to apply the style against. For example, to change the text color across the whole table, use the color property against the <table> tag.

Can we use font tag with table in HTML?

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 . FYI, quotes are mandatory. But you're right, CSS, inline or otherwise, is the way to go, as FONT tag is not longer supported.


2 Answers

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 .

like image 169
LexH Avatar answered Oct 01 '22 12:10

LexH


Enclose your code with the html and body tags. Size attribute does not correspond to font-size and it looks like its domain does not go beyond value 7. Furthermore font tag is not supported in HTML5. Consider this code for your case

<!DOCTYPE html> <html> <body>  <font size="2" face="Courier New" > <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 size="5" face="Courier New" > <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> </body> </html> 
like image 39
Jocimar Candido Avatar answered Oct 01 '22 13:10

Jocimar Candido