CSS font properties
With CSS font properties, you can specify the font a text will be displayed in and the size of the text.
This tutorial focuses on:
- Setting text font
- Setting text size
Setting text font
Text font is set with the font-family property. You can specify a list of fonts with this property and the web browser will use the first font that is found on the user's computer.
Example:
<html>
<head>
<title>Background properties</title>
<style type="text/css">
h1 {font-family: helvetica, georgia;}
p {font-family: tahoma, "trebuchet ms"}
</style>
</head>
<body>
<h1>Some text</h1>
<p>Some more text</p>
</body>
</html>
Output:
Some text
Some more text
Setting text size
Text size is set with the font-size property. You can specify a size from a set of prefixed sizes or set your own size for text.
Some prefixed text sizes: - x-small, small, medium, large, x-large
Example:
<html>
<head>
<title>Setting a background image</title>
<style type="text/css">
h1 {font-size: 40px;}
p {font-size: large;}
</style>
</head>
<body>
<h1>Some text</h1>
<p>
A sentence in a paragraph. Another sentence in a paragraph.
</p>
</body>
</html>
Output:
Some text
A sentence in a paragraph. Another sentence in a paragraph.