Monday, January 25, 2010

Section 9.18. Adding style to your fonts










9.18. Adding style to your fonts


You're familiar with italic text, right? Italic text is slanted, and sometimes has extra curly serifs. For example, compare these two styles
:



not italic
italic
The italic text is slanted to the right and has extra curls on the serifs.




You can add an italic style to your text in CSS using the font-style

property:



font-style: italic;
A common mistake is to write "italic" as "italics". If you do, you won't see italic text.
So remember to check your spelling.




However, not all fonts support the italic style, so what you get instead is called oblique text. Oblique text is also slanted text, but rather than using a specially designed slanted set of characters in the font, the browser just applies a slant to the normal letters. Compare these non oblique and oblique styles:



not oblique
oblique
The regular letters are slanted to the right in the oblique style.



You can use the font-style property to get oblique text too, like this:



font-style: oblique;



In practice, you're going to find that, depending on your choice of font and browser, sometimes the two styles will look identical, and sometimes they won't. So, unless italic versus oblique is very important to you, choose one and move on. If, on the other hand, it is important, you'll need to test your font and browser combination for the best effect.


Italic and oblique styles are two styles that give fonts a slanted appearance.


Unless you can control the fonts and browsers your visitors are using, you'll find that sometimes you get italic, and sometimes oblique, no matter which style you specify.


So just go with italic and don't worry about the differences (you probably can't control them anyway).












No comments: