“CSS italic” is a term you might search for when you are trying to find the right CSS property to add a little extra emphasis to some text on an HTML page. And it only makes sense because there are over 500 CSS properties in use today. You are not alone. Finding the right CSS selector when you need it can be hard. This article is here to provide you with all you want to know about using CSS to italicize text.

CSS Stylesheet on a computer screen

What is italic text, and why would you use it?

The most common reason to use italic text on your HTML pages is to emphasize that section of text for visitors. It can make part of your page really stand out. But it is not something that should be overused. After all, if everything on the page has emphasis, nothing really does. Or you may have to use it to fit the style guide for a website. Sometimes, it is used to denote the title or name of specific works or objects, like in this sentence: The Titanic was a ship that sank in the early 20th century.

The Web Developer Bootcamp 2022

Last Updated July 2022

  • 615 lectures
  • All Levels
4.7 (250,037)

COMPLETELY REDONE – The only course you need to learn web development – HTML, CSS, JS, Node, and More! | By Colt Steele

Explore Course

CSS italic: how to italicize text with the font-style property

The most common, modern way to italicize HTML text is by using CSS. You can do this with the CSS font-style property. Here is the syntax of the font-style property:

font-style: normal|italic|oblique|initial|inherit;

As you can see above, there are five values you can set the font-style property to. Here is what each of them stands for:

So all you have to do to italicize text in HTML is set the font-style property to “italic.” There are a few ways to do this, depending on how your HTML page and code project is set up. The preferred way is using an external CSS stylesheet. Here is an example of a CSS style sheet that is using font-style to make text italic:

body {
  background-color: white;
}

h1 {
  color: blue;
}

p {
  color: black;
}

.italicized {
  font-style: italic;
}

There are a few other styles here that target specific elements like the whole body, the H1 tags, and the paragraphs, but we want to focus on the last one that targets a specific class called “italicized.” Below is the HTML page where this stylesheet is included if we named it “stylesheet.css.”

<!DOCTYPE html>
<html>
  <head>
    <link rel=”stylesheet” href=”stylesheet.css”>
  </head>
  <body>

    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
    <div class=”italicized”>This will be italicized.</div>

  </body>
</html>

Top courses in CSS

Build Responsive Real-World Websites with HTML and CSS
Jonas Schmedtmann
4.8 (86,431)
Bestseller
Advanced CSS and Sass: Flexbox, Grid, Animations and More!
Jonas Schmedtmann
4.8 (38,644)
Bestseller
CSS – The Complete Guide 2023 (incl. Flexbox, Grid & Sass)
Academind by Maximilian Schwarzmüller, Maximilian Schwarzmüller, Manuel Lorenz
4.7 (15,283)
Bestseller
Understanding HTML and CSS
Anthony Alicea
4.8 (1,070)
50 Projects In 50 Days – HTML, CSS & JavaScript
Brad Traversy, Florin Pop
4.7 (8,925)

More CSS Courses

Another way is to embed the CSS styles directly into the HTML file, like this:

<!DOCTYPE html>
<html>
  <head>
    <style>
    body {
        background-color: white;
      }

      h1 {
        color: blue;
      }

      p {
        color: black;
      }

      .italicized {
        font-style: italic;
      }
    </style>
  </head>
  <body>

    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
    <div class=”italicized”>This will be italicized.</div>

  </body>
</html>

The final way to italicize text with CSS is using inline CSS. This method works in a pinch but is not preferred because it can make your HTML pages messy by mixing styles with your HTML.

<!DOCTYPE html>
<html>
  <head></head>
  <body>

    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
    <div style=”font-style:italic;”>This will be italicized.</div>

  </body>
</html>

There are some things you should know about using CSS to make your text italic. You don’t always get what you expect.

Questions often asked about italicizing text with CSS

Fonts can be confusing, and you don’t always get what you want when you italicize HTML with CSS. Here are some common questions about CSS and italic:

What is faux italic?

How your browser makes a font italic depends on what font family you are using on the text. Each font family usually has more than one version of the font to cover all of the font-styles you could possibly use in your stylesheets. When you set the font-style to italic, your browser will look for the specific italic version of the font to apply to an element. When it doesn’t find an italic version of the font in the font family, it will attempt to fake it, and this will almost always end up looking bad. This is the reason you have to be sure to include the italic version of any custom fonts you are using if you plan to use italic text on your website.

How do I link to the italic version of a font?

To link to the italic version of a custom font, use the “font-face” CSS rule. The font-face rule will tell the browser which font to use when you set font-style to italic. Here is an example of its use:

@font-face {
  font-family: ‘Ubuntu’;
      src: url(‘Ubuntu-RI-webfont.eot’);
      src: url(‘Ubuntu-RI-webfont.eot?#iefix’) format(’embedded-opentype’),
          url(‘Ubuntu-RI-webfont.woff’) format(‘woff’),
          url(‘Ubuntu-RI-webfont.ttf’) format(‘truetype’),
          url(‘Ubuntu-RI-webfont.svg#UbuntuItalic’) format(‘svg’);
  font-weight: normal;
  font-style: italic;
}

Assuming you have other font-face rules set up for normal and other font-styles with other versions of the Ubuntu font, you can set the font family of the body of your HTML to “Ubuntu” like this:

body {
  font-family: “Ubuntu”, sans-serif;
}

Now, when you set the font-style of a specific element, class, or id to italic, the browser will use this specific version of the Ubuntu font. Otherwise, the browser will try its best to make the font look italic, and the text will be emphasized, but the result won’t be what you are looking for.

Ready to learn more about CSS? You can read our article on CSS uppercase, lowercase, and headcase to learn more about styling text in HTML or our article on CSS flexbox vs. grid. And when you are ready to take a full course, we have many top CSS courses here at Udemy for beginners as well as advanced students.

Page Last Updated: April 2022