CSS - Font Attribute & Example

Font-size – denotes absolute size (xx-small, x-small, small, medium, larger, x-larger, ss- large), relative size (larger, smaller), a number (of pixel), percentage (of the parent element’s size)

CSS Font Attribute

Font-family – sequence of font family name separated by comma

Font-style - normal , italic or oblique


Font-weight – normal , bold, bolder, lighter or one of the nine numerical values (100,200,300,400,500,600,700,800,900)


Font-size – denotes absolute size (xx-small, x-small, small, medium, larger, x-larger, ss- large), relative size (larger, smaller), a number (of pixel), percentage (of the parent element’s size)

CSS Code

<style type = 'text/css'>
Hi {font-family: Arial, Helvetica}
P {font:size = 12 pt; font-style : italic}
</style>

HTML / CSS Code

<html>
 <head>
  <style type='text/css'>
   p{
    font-family:Courier,Trebuchet,Verdana;
    font-size:12pt;
    font-style:italc;
   }
  </style>
 </head>
 <body>
  <p> Hello World How are You Hello World How are You Hello World How are You Hello World How are You Hello World How are You</p>
 </body>
</html>

Output

Hello World How are You Hello World How are You Hello World How are You Hello World How are You Hello World How are You
Font-family
It specifies the font to be used
Font-size
It specifies the size of the font used.
Font-style
It specifies whether the font should be normal, italic or oblique.
Font-weight
It specifies whether the font should be normal, bolder, or lighter.

You May Also Like...