You are here: Reference > JavaScript > client-side > style handling > properties > fontStyle

fontStyle style property

Browser support:
Specifies or returns whether the style of the font is normal, italic or oblique.


You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: font-style

Possible values:

The type of this property is string.
 One of the following values: 
Takes the value of this property from the computed style of the parent element.
Font should be displayed in italic.
Default. Font is normal.
Font should be displayed in oblique.
Default: normal.

Example HTML code 1:

This example illustrates the use of the font-style property:
        .normal {
            font-style: normal;
        .italic {
            font-style: italic;
    <span class="normal">font-style: normal</span><br />
    <span class="italic">font-style: italic</span>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the fontStyle property in JavaScript:
    <script type="text/javascript">
        function ChangeFont (selectTag) {
            // Returns the index of the selected option
            var whichSelected = selectTag.selectedIndex;

            // Returns the selected options values
            var selectState = selectTag.options[whichSelected].text;

            var fontTest = document.getElementById ("fontTest");            
   = selectState;
    <span id="fontTest">
        Sample multiline text <br />change it!

    <br />
    <select onchange="ChangeFont (this);" size="3">
        <option />italic
        <option selected="selected" />normal
        <option />oblique
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content