How to set the font style with CSS

The font-style property is used to switch between styles that are provided by a particular font. The possible font styles are italic or oblique, and they are part of the font itself.

The possible values for the font-style property are: normal, italic or oblique.

Note: for the most part, most fonts with the italic or oblique value are almost indistinguishable in how they are displayed on web browsers.

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

<style type="text/css">
p.one
{ font-style: italic; }
p.two
{ font-style: normal; }
p.three
{ font-style: oblique; }
</style>

</head>
<body>
<p class="one">
This text has an italic font style.
</p>
<p class="two">
This is text has a normal font style.
</p>
<p class="three">
This is text has a oblique font style.
</p>
</body>
</html>

The code above creates the paragraphs below.

This text has an italic font style.

This is text has a normal font style.

This is text has a oblique font style.

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

Free Website Templates

Free Web Tools

Recommended Websites