Web Development Tutorials.com

How to specify the font-family with CSS


Click Here for CoffeeCup Website Design Software   GoDaddy.com Hosting & Servers

The below HTML and CSS code example shows you how to specify the font-family with CSS.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>this is the title of the web page</title>

<style type="text/css">

</style>

</head>
<body>

<p style="font-family: times;">
This is a paragraph with a font-family attribute with a value of times.
</p>
<p style="font-family: courier;">
This is a paragraph with a font-family attribute with a value of courier.
</p>
<p style="font-family: 'sans-serif';">
This is a paragraph with a font-family attribute with a value of "sans-serif".
</p>

</body>
</html>

The above HTML and CSS code makes the paragraphs below, each with a different font-family style.

This is a paragraph with a font-family attribute with a value of times.

This is a paragraph with a font-family attribute with a value of courier.

This is a paragraph with a font-family attribute with a value of "sans-serif".

Use the text editor below to practice setting the font-family of text.