CSS Fonts
CSS font properties define the font family, boldness, size, and the style of a text.
CSS Fonts
CSS font properties define the font family, boldness, size, and the style of a text.
Example 1: Font Family
In CSS, there are two types of font family names:
- generic family: a group of font families with a similar look (like "Serif" or "Monospace")
- font family: a specific font family (like "Times New Roman" or "Arial")
This is a serif font.
This is a sans-serif font.
This is a monospace font.
Example 2: Font Style
The font-style property is mostly used to specify italic text.
This text is shown in normal style.
This text is shown in italic.
This text is shown in oblique.
Example 3: Font Weight
The font-weight property specifies the weight of a font.
Normal font weight.
Lighter font weight.
Bold font weight.
Thick font weight (900).
Example 4: Font Size
The font-size property sets the size of the text.
This is 40px text.
This is 30px text.
This is 14px text.
Example 5: Google Fonts
If you do not want to use any of the standard fonts in HTML, you can use Google Fonts.
Making the Web Beautiful!
Example
p {
font-family: "Times New Roman", Times, serif;
font-style: italic;
font-size: 40px;
font-weight: bold;
}