Posts

HTML font Tag

 

HTML <font> tag (Not Supported in HTML5)

HTML <font> tag is used to define the font style for the text contained within it. It defines the font size, color, and face or the text in an HTML document.

NOTE: Do not use HTML <font> tag as it is deprecated in HTML5, so you can use CSS properties to change the font size, face, color, etc.

Syntax

  1. <font size=" " color=" " face=" "> Content....</font>  

Following are some specifications about the HTML <font> tag

DisplayInline
Start tag/End tagBoth Start and End tag
UsageFont Style

Example 1

  1. <!DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.  <title>Font Tag</title>  
  5.  </head>  
  6.  <body>  
  7.  <h2>Example of font tag</h2>  
  8.  <p>This is normal text without any font styling</p>  
  9.   <p>  
  10.     <font color="blue">Text with normal size and default face</font>  
  11.   </p>  
  12.   <p>  
  13.     <font size="5" color="green">Text with Increased size and default face</font>  
  14.   </p>  
  15.   <p>  
  16.     <font color="red" face="cursive">Text with Changed face</font>  
  17.   </p>  
  18. </body>  
  19. </html>  
Test it Now

Output:

HTML font tag

Using CSS

The same effect can be achieved using CSS properties as in below example:

  1. <!DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.  <title>Font Tag</title>  
  5.  </head>  
  6.  <body>  
  7. <h2>Change font using CSS</h2>  
  8.  <p>This is normal text without any font styling</p>  
  9.  <p style="color: blue;">Text with normal size and default face</p>  
  10.  <p style="font-size: 25px; color: green;">Text with Increased size and default face </p>  
  11.  <p style="font-family: cursive; color: red;">Text with Changed face</p>  
  12. </body>  
  13. </html>  

Test it Now

Output:

HTML font tag

Attribute

Tag-specific attribute

AttributeValueDescription
colodrgb(X,X,X)
#xxxxx
color_name
It specifies the color of the content. (Not Supported in HTML5)
facefont_familyIt specifies the typeface of the content. (Not Supported in HTML5)
sizenumberIt specifies the size of the content. (Not Supported in HTML5)

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<font>YesYesYesYesYes

Post a Comment

© HTML Programming. The Best Codder All rights reserved. Distributed by