Recipe 2.4. Enforcing Font Sizes


Problem

You want to override control over font sizes.

Solution

Use the !important rule to override a user's style sheet rules:

p {  font-size: 12px !important; }

Discussion

The !important rule consists of an exclamation mark (!) followed immediately by the word important.

In some browsers, a user can have a style sheet set up for browsing the Web that enables him to set font sizes (and other CSS properties) to his liking. However, as a designer of a web document, you may want to make sure your designs render in the manner you planned. The !important rule gives you a little insurance that your designs remain intact. (However, the nature of the medium means that designs are never precise or "pixel-perfect" from one display to another.)

Although you, as the designer, write the !important CSS rules, the user can also write these rules in his own style sheet. And in the CSS 2 specification, !important rules that the user writes override any !important rules the designer writes.

See Also

The CSS 2.1 specification on !important rules at http://www.w3.org/TR/CSS21/cascade.html#important-rules.




CSS Cookbook
CSS Cookbook, 2nd Edition
ISBN: 0596527411
EAN: 2147483647
Year: 2006
Pages: 235

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net