CSS Property: font-style
[this page | pdf | back links]
The CSS (CSS1) font-style property indicates the font
style to use for text in an element.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
italic
|
Italic text
|
normal
|
(default value). Normal
text
|
oblique
|
Oblique text
|
Default Value:
|
normal
|
JavaScript syntax:
|
e.g. object.style.fontStyle="italic"
|
Inherited:
|
Yes
|
Animatable:
|
No
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 100px; border: 1px dotted black;}
.x1 {font-style: italic;}
</style>
</head>
<body>
Element with default property<br>
<div>abcdefgh</div><br>
Property set using in-file HTML style<br>
<div class="x1">abcdefgh</div><br>
Property set using JavaScript<br>
<div id="x2">abcdefgh</div>
<script>
document.getElementById("x2").style.fontStyle = "italic";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyFontStyle() {
var x = document.createElement("DIV"); x.style.fontStyle = "italic"; return (window.getComputedStyle(x, null).fontStyle == "italic");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties