The CSS Font Attribute

Once again, this is a composite attribute used to assign the (in the wordprocessing sense) font, its size, style and weight. The assignment determines the manner in which text within the element is drawn. If em-sizing is used this specification will also influence the layout of all contained elements. The sub-attributes are

The shorthand font attribute setting bears the form

font:bold italic 0.8em "Comic Sans MS";

Needless to say, in shorthand mode all font names that contain spaces should be wrapped in quotes. Unlike with other shorthand properties browsers are very picky about the order of sub-attributes here. The alternatives acceptable to all three browsers discussed in these pages are listed below

Any other combination will be treated as being erroneous.

These attributes are inherited - i.e. in a child element, if not assigned, the corresponding values in the parent container are used.

Jump To...

Colophon