CSS Tutorial
Handling Font In CSS
CSS provide several properties for styling the font of the text,
including changing their face, controlling their size and
boldness.
⚫ There are 5 properties for setting font and they are:
⚪ font-family
The font-family property is used to specify the font to be used to
render the text.
Font Group Name | Font Names |
---|---|
Sans Serif | Arial, Arial Black, Trebuchet, Verdana |
Serif | Georgia, Times New Roman |
Monospace | Courier New, Andale Mono |
Cursive | Apple Chancery, Comic Sans, Snell |
Fantasy | Impact, Stencil |
The font-style property is used to set the font face style for the text content of an element.
The font style can be:
>normal
>italic
>oblique
The default value is normal.
OBLIQUE v/s ITALIC
The Oblique Style uses the same font as Normal (non-italic version of the font-type / font-face) but skews (slants) it to the right before presenting it to the screen.
While the Italic Style uses a Italic type/version of the font, most of the time almost all fonts have a Italic version of the font which has special characters defined for it
⚪ font-weight
The font-weight property specifies the weight or boldness of the font.
This property can take one of the following values:
> normal
> bold
> bolder
> lighter
> 100, 200, 300, 400, 500, 600, 700, 800, 900 and
> inherit
⚪ font-size
The font-size property is used to set the size of font for the text content of an element.
There are several ways to specify the font size values like:
>Using pixels
>Using em or percentage
>Using special keywords
⚪ font-variant
The font-variant property allows the text to be displayed in a special small-caps variation.
Small-caps or small capital letters are slightly different to normal capital letters, in which lowercase letters appear as smaller versions of the corresponding uppercase letters.