The CSS reference

"font-style" - css property (v. css 1)

  • To specify the font style for text.
  • Initial value: normal
  • The property is inherited
  • HTML usage: all elements
  • Browsers that support the font-style - property :
    Internet Explorer Mozilla Firefox Opera Google Chrome Apple Safari

Possible font-style values:

value Comments CSS
normal Selects a font that is classified as 'normal' in the UA's font database. 1
italic Selects a font that is labeled 'italic', or, if that is not available, one labeled 'oblique'. 1
oblique Selects a font that is labeled 'oblique' 1
inherit Will inherit the value from parent specification. This property value is new with CSS 2. 2

Property "font-style" example:

<!DOCTYPE HTML >
<html  >
  <head>
    <title>Test</title>
    <style type="text/css">
      div {border: blue 1px solid; color:black;
           padding: .5em .5em .5em .5em; width: 400px;
      }
      .italic { font-style: italic; }
      .oblique { font-style: oblique; }
    </style>
  </head>
  <body>
    <br>font-style: italic; <br>
    <div class="italic">
      Selects a font that is labeled 'italic', or,
      if that is not available, one labeled 'oblique'.
    </div>
    <br>font-style: oblique;<br>
    <div class="oblique">
      Selects a font that is labeled 'oblique'.
    </div>
  </body>
</html>

Javascript access:

// To SET values ([o] is the target object)
[o].style.fontStyle="font-style values"
// To GET values you must first get the computed style object
// To get that object in IE or Opera:
var cStyle=[o].currentStyle;
// To get that object in Firefox, Chrome or Safari (w3c-type):
var cStyle=window.getComputedStyle([o],null)
// To GET the property value:
var value=cStyle.fontStyle;
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.