Home > Article > Web Front-end > Which property is used to make the font italic?
In CSS, we can use the ‘font-style’ attribute to set the style of the font. We can use different styles as the value of the font-style property, "oblique" is one of them.
Basically, a "slanted" font is a sloppy version of text where we set the angle to make the text less or more slanted. Here we'll make the fonts italic in each example.
Users can use the font-style property of CSS to make the font italic according to the following syntax.
font-style: oblique;
In the example below, we create two
tags and add text to them to display on the web page. Additionally, we applied the "font-style: normal" CSS property to the first
tag and the "font-style: oblique" CSS property to the second
tag.
In the output, uesrs can observe that the italic font is more sloppy than the normal font.
<html> <head> <style> .normal { font-style: normal; font-size: 1.5rem; } .oblique { font-style: oblique; font-size: 1.5rem; } </style> </head> <body> <h2>Using the <i> font-stlye: oblique </i> to make font oblique.</h2> <p class = "normal"> This font is Normal font. </p> <p class = "oblique"> This font is <i> oblique </i> font. </p> </body> </html>
In the example below, we also added an angle using the "oblique" font style attribute. The limitation is that this angle only works in the Firefox browser.
We created three different div elements and added text to them. In CSS, we apply the font-style oblique property to all fonts at different angles. In the output, the user can observe that as the angle increases, the slope of the font increases.
<html> <head> <style> .one { font-style: oblique 40deg; font-size: 1.5rem; } .two { font-style: oblique 80deg; font-size: 1.5rem; } .three { font-style: oblique 30deg; font-size: 1.5rem; } </style> </head> <body> <h2>Using the <i>font-stlye: oblique</i> to make font oblique.</h2> <p class = "one">The font style is oblique and slope is 40deg.</p> <p class = "two">The font style is oblique and slope is 80deg.</p> <p class = "three">The font style is oblique and slope is 120deg.</p> </body> </html>
In the example below, we have created a div element and added some nested div elements at multiple levels. We used the ‘font-style: oblique’ CSS property for the parent div, and the user can see that all fonts of that div are oblique, including the child div elements.
<html> <head> <style> .test { font-style: oblique; font-size: 1.5rem; } </style> </head> <body> <h2>Using the <i>font-stlye: oblique</i> to make font oblique.</h2> <div class = "test"> This is a parent div. <div> This is a child div with font-style: oblique. <div> This is another nested child div with font-style: oblique. </div> </div> </div> </div> </body> </html>
Users learned to use the font-style attribute to create italic fonts. It is almost similar to the "italic" font style in that it also creates a cursive or cursive font.
The above is the detailed content of Which property is used to make the font italic?. For more information, please follow other related articles on the PHP Chinese website!