fontStyle Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:fontStyle

Description

The fontStyle property sets or gets whether the style of the font is normal, italic or oblique.

Property Values

Value Description
normal Font is normal. This is default
italic Font is in italic
oblique Font is in oblique
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: normal
Return Value: A String, representing the font style of the text in the element
CSS VersionCSS1

Set the font for a <p> element to "italic":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="font-style:italic;">This is a paragraph.</p>

<button type="button" onclick="myFunction()">Test</button>

<script>
function myFunction() {//from   ww w .  java2  s .  co m
    document.getElementById("myP").style.fontStyle = 'italic';
}
</script>

</body>
</html>

Related Tutorials