CSS font configuration shorthand rule

When creating CSS classes with fonts configuration within CSS you may be doing this:




font-weight: bold;

font-style: italic;

font-variant: small-caps;

font-size: 1em;

line-height: 1.2em;

font-family: arial,verdana,sans-serif


You can achieve the same thing by using CSS shorthand property for font as follows:


font: bold italic small-caps 1em/1.2em arial,verdana,sans-serif


Much better! Remember: This CSS shorthand version will only work if you're specifying both the font-size and the font-family. The font-family command must always be at the very end of this shorthand command, and font-size must come directly before this. Also, if you don't specify the font-weight, font-style, or font-variant then these values will automatically default to a value of normal, so do bear this in mind too.

No comments:

Post a Comment