CSS Text Code Tutorials

How to set the font style using CSS

The code below shows you how to set the font style using 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>Web Development Tutorials.com</title>

<style type="text/css">
p {font-style: italic;}
p.one {font-style: normal;}
p.two {font-style: times;}
p.three {font-style: arial;}
p.four {font-style: sans-serif;}
p.five {font-style: oblique;}
</style>

</head>
<body>
<p>
This is a paragraph with an italic font style.
</p>
<p class="one">
This is a paragraph with a normal font style.
</p>
<p class="two">
This is a paragraph with a times font style.
</p>
<p class="three">
This is a paragraph with an arial font style.
</p>
<p class="four">
This is a paragraph with a sans-serif font style.
</p>
<p class="five">
This is a paragraph with an oblique font style.
</p>
</body>
</html>

The code above creates the paragraphs below.

This is a paragraph with an italic font style.

This is a paragraph with a normal font style.

This is a paragraph with a times font style.

This is a paragraph with an arial font style.

This is a paragraph with a sans-serif font style.

This is a paragraph with an oblique font style.

Use the text editor below to practice what you have learned.