HTML DOM fontStyle Property
Complete Style Object Reference
Definition and Usage
The fontStyle property sets the font-style of an element.
Syntax
Object.style.fontStyle=normal|italic|oblique
|
Possible Values
Value |
Description |
normal |
The browser displays a normal style |
italic |
The browser displays an italic style |
oblique |
The browser displays an oblique style |
Example
The following example adds an italic style to the text:
<html>
<head>
<script type="text/javascript">
function setFontStyle()
{
document.getElementById("p1").style.fontStyle="italic";
}
</script>
</head>
<body>
<p id="p1">This is an example paragraph.</p>
<input type="button" onclick="setFontStyle()"
value="Change font-style" />
</body>
</html>
|
Try-It-Yourself Demos
fontStyle - Change the style of a text
Complete Style Object Reference
|