CSS Font
CSS Font
CSS Font
Example
body {font-size:100%;}
h1 {font-size:2.5em;}
h2 {font-size:1.875em;}
p {font-size:0.875em;}
Try it yourself
Our code now works great! It shows the same text size in all browsers, and allows all browsers to
zoom or resize the text!
More Examples
Set the boldness of the font
This example demonstrates how to set the boldness of a font.
Set the variant of the font
This example demonstrates how to set the variant of a font.
All the font properties in one declaration
This example demonstrates how to use the shorthand property for setting all of the font properties
in one declaration.
Description
Values
CSS
font
font-style
font-variant
font-weight
font-size/line-height
font-family
caption
icon
menu
message-box
small-caption
status-bar
inherit
font-family
family-name
generic-family
inherit
font-size
xx-small
x-small
small
medium
large
x-large
xx-large
smaller
larger
length
%
inherit
font-style
normal
italic
oblique
inherit
font-variant
font-weight
Previous
normal
bold
bolder
lighter
100
200
300
400
500
600
700
800
900
inherit
Next Chapter
Product Spotlight
file:///E:/Document/W3School/W3schools Offline Version/www.w3schools.com/css/css_font.asp
3/4