CSS font-style Property

It is used to specify the font style of an HTML element. It can be “normal, italic or oblique”. 

Syntax: 

font-style: style name;

Example: In this example with CSS: ‘gfg’ class uses bold ‘Times New Roman’ font, 40px size, green color, centered text; ‘geeks’ class applies italic font style with centered text.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>font-style property</title>
    <style>
        .gfg {
            font-style: normal;
            font-family: "Times New Roman";
            font-weight: bold;
            font-size: 40px;
            color: #090;
            text-align: center;
        }

        .geeks {
            font-style: italic;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="gfg">w3wiki</div>
    <div class="geeks">
      A computer science portal for geeks
    </div>
</body>

</html>

Output: 

CSS Fonts

CSS fonts are used to style the text within HTML elements. The font-family property specifies the typeface, while font-size, font-weight, and font-style control the size, thickness, and style of the text. Combining these properties enhances the typography and readability of web content.

Example: In this example, we will use a few CSS Font properties.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>CSS Font</title>
    <style>
        .gfg {
            font-family: "Arial, Helvetica, sans-serif";
            font-size: 60px;
            color: #090;
            text-align: center;
        }

        .geeks {
            font-family: "Comic Sans MS", cursive, sans-serif;
            font-variant:small-caps;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="gfg">w3wiki</div>
    <div class="geeks">
      A computer science portal for geeks
    </div>
</body>

</html>

Output: 

There are many font properties in CSS which are mentioned and briefly discussed below:

Below few examples are given from CSS Font Collection :

Table of Content

  • CSS font-family Property
  • CSS font-style Property
  • CSS font-weight Property
  • CSS font-variant Property
  • CSS font-size Property
  • CSS font-stretch Property
  • CSS font-kerning Property

Similar Reads

CSS font-family Property

It is used to set the font type of an HTML element. It holds several font names as a fallback system....

CSS font-style Property

It is used to specify the font style of an HTML element. It can be “normal, italic or oblique”....

CSS font-weight Property

It is used to set the boldness of the font. Its value can be “normal, bold, lighter, bolder”....

CSS font-variant Property

It is used to create the small-caps effect. It can be “normal or small-caps”....

CSS font-size Property

It is used to set the font size of an HTML element. The font-size can be set in different ways like in “pixels, percentage, em or we can set values like small, large” etc....

CSS font-stretch Property

The CSS font-stretch property adjusts the width of selected fonts, allowing you to make text narrower or wider. It accepts values like normal, condensed, expanded, and specific percentages....

CSS font-kerning Property

The CSS font-kerning property controls the use of kerning, which adjusts the space between characters for better readability. It can take values like auto, normal, and none to enable, use default kerning, or disable kerning, respectively....

Contact Us