You can italicize a text using the CSS property, font-style
. This property sets the texts to other styles too such as normal
and oblique
. The default value for the CSS property, font-style
is normal
for every text.
The general syntax
The general syntax of the CSS property, font-style is as follows
font-style: value;
If you need to italicize a text, you need to set the value as italic
. The other keywords that this property accepts are
normal
- Sets the text style to normal.oblique
- Sets the text style to oblique.initial
- Sets the property to its default styleinherit
- Inherits the value of the property from the parent element.
A coding sample
Here comes a simple example, shows the CSS property, font-style
in use
<!DOCTYPE html>
<html lang="en">
<head>
<title>A Sample Web Page</title>
<style>
.sample1 {
font-style: italic;
}
.sample2 {
font-style: normal;
}
.sample3 {
font-style: oblique;
}
</style>
</head>
<body>
<p class="sample1">Sample Semtence 1</p>
<p class="sample2">Sample Sentence 2</p>
<p class="sample3">Smaple Sentence 3</p>
</body>
</html>
The above example set the CSS font-style
property for texts of three sentences. It changes the font style of the sentence with class sample1
to italic
. For the other two sentences, the example set the property with different values.