In CSS, there are two types of font family names:
The font family of a text is set with the font-family property.
The font-family property should hold several font names as a "fallback" system. If the
browser does not support the first font, it tries the next font.
Start with the font you want, and end with a generic family, to let the browser pick a similar
font in the generic family, if no other fonts are available.
Note: If the name of a font family is more than one word, it must be in quotation marks,
like font-family: "Times New Roman".
More than one font family is specified in a comma-separated list:
For more commonly used font combinations, look at our Web Safe
The font-style property is mostly used to specify italic text.
This property has three values:
The font-size property sets the size of the text.
Being able to manage the text size is important in web design. However, you should not use font
size adjustments to make paragraphs look like headings, or headings look like paragraphs.
Always use the proper HTML tags, like <h1> - <h6> for headings and <p> for
The font-size value can be an absolute, or relative size.
If you do'nt specify a font size, the default size for normal text, like paragraphs, is 16px
Setting the text size with pixels, gives you full control over the text size:
The example above allows Firefox, Chrome, and Safari to resize the text, but not Internet
The text can be resized in all browsers using the zoom tool (however, this resizes the entire
page, not just the text).
To avoid the resizing problem with Internet Explorer, many developers use em instead of
The em size unit is recommended by the W3C.
1em is equal to the current font size. The default text size in browsers is 16px. So, the default
size of 1em is 16px.
The size can be calculated from pixels to em using this formula: pixels/16=em
In the example above, the text size in em is the same as the previous example in pixels. However,
with the em size, it is possible to adjust the text size in all browsers.
Unfortunately, there is still a problem with IE. When resizing the text, it becomes larger than
it should when made larger, and smaller than it should when made smaller.
The solution that works in all browsers, is to set a default font-size in percent for the body
Our code now works great! It shows the same text size in all browsers, and allows all browsers to
zoom or resize the text
Set the boldness of the fontThis
example demonstrates how to set the boldness of a font.
Set the variant of the fontThis
example demonstrates how to set the variant of a font.
All the font properties in one
declarationThis example demonstrates how to use the shorthand property for setting all
of the font properties in one declaration.
The number in the "CSS" column indicates in which CSS version the property is defined
(CSS1 or CSS2).
Your Query was successfully sent!