Font Tag in HTML

 Font Tag in HTML


Font tag is very helpful hen you want to write some text in different font style like Times New Roman, Verdana, Arial etc. Also you can set the color and size of fonts by using font tag attributes. Font face only works if it is installed in your machine or system. 

In HTML programming, you can use <font>  to implement font tag.

In HTML programming if you want to set styles for font tags in complete document than you can use base font tag. This style will be inherited by every font tag in document if font tag is not having self styles. For this we use <basefont> tag in HTML. <basefont> tag is older tag and it is supported by HTML4 version not in HTML5 or more.

Note:- Instead of using font tag you may use CSS style because font tag will be not applicable after some time due to CSS.

<basefont> and <font> both tag contains same attributes. <basefont> tag does not have closing tag.   

Attributes of Font (<font>) Tag in HTML-

1. Face - This attribute set the font-family like Times New Roman, Arial, Verdana etc. for fonts.

2. Color - This attribute set the color of text or fonts written between the opening and closing font tag. 

3. Size - This attribute set the font-size written between the opening and closing font tag. Size of font is
               by default 3 and its minimum value is 1 and maximum value is 7. You can use +(plus) and 
               -(minus) operator symbol before value that indicate increment and decrement respectively in
               default size according to size value. For an example we know that default font size is 3 and we
               use font tag with size= +2 than the text size will be 5 and if we use font tag with size= -1 than
               the text size will be 2.  

Let us Discuss about how to use the Font tag in HTML programming with its Attributes-

<HTML>
 
      <HEAD>
  
           <TITLE> Font Tag in HTML </TITLE>

      </HEAD>

      <BODY>
          
          
          <FONT FACE="TIMES NEW ROMAN" SIZE="1" COLOR="RED">
             Hello Viewers this text will be in Red color, Size will be 5 with Times new Roman font Style.
          </FONT> 
         
          <FONT FACE="ARIAL" SIZE="2" COLOR="BROWN">
             Hello Viewers this text will be in Brown color, Size will be 2 with Arial font Style.
          </FONT> 

          <FONT FACE="ARIAL" SIZE="+1" COLOR="BLUE">
             Hello Viewers now this text size will be 3+1=4 where 3 is default font size.
          </FONT> 

          <FONT FACE="ARIAL" SIZE="-1" COLOR="BROWN">
             Hello Viewers now this text size will be 3-1=2 where 3 is default font size.
          </FONT> 
    
      </BODY>

</HTML>


Output-


Font Tag Output
Font Tag Output

No comments:

Post a Comment