Openwave Mobile Browser 6.1 and 6.2: XHTML Mobile Profile and CSS Reference

Section 27 out of 38 total sections
Current chapter: CSS Reference

Font Properties

You can use the font properties to set the font family, style, weight, and size of text.

IMPORTANT  Although Openwave Mobile Browser supports the CSS font properties described in this section, actual support for fonts depends entirely on the individual makes and models of mobile phones. It's essential to learn the features of the phone models in your market to determine the fonts you can use for your wireless applications.



font-family

Sets a specific or generic font family for text.

Values

Specific font family names (for example, "arial"); generic font family keywords: serif, sans-serif, cursive, fantasy, monospace; the standard keyword inherit.

See Keywords for more information.

Default Value

Depends on the phone make and model.

Useful For

All elements that contain text.

Inherited

Yes.

Notes

Enclose real font family names in quotes (for example "Times New Roman"); do not enclose generic font family keywords in quotes (for example, serif).

You can include a comma-separated series of font-family values to set backup values If one value isn't supported by a phone, the browser will try the next value, in left-to-right order.

Example
h1 {font-family: "helvetica", "arial", sans-serif}

Displays the text of first-level heads in Helvetica, if available. If not, tries Arial, and then any available sans-serif font. If none is available, the browser uses the default font for the phone.



font-style

Sets the font "style" for text: normal (also called "roman"), italic, or oblique.

Values

normal, italic, oblique, inherit

See Keywords for more information.

Default Value

normal

Useful For

All elements that contain text.

Inherited

Yes.

Notes

When you specify an italic font, the browser tries to use a font with "italic" in its name or failing that, one with "oblique" in its name. Italic fonts are also sometimes named "cursive" or "kursive."

When you specify an oblique font, the browser tries to use a font with "oblique" in its name or failing that, one with "italic" in its name. Oblique fonts are also sometimes named "slanted" or "inclined." Some oblique fonts are generated by electronically slanting a roman font.

Example
h4 {font-style: italic}

Displays the heading in italics.



font-variant

Openwave Mobile Browser does not use this property.



font-weight

Sets a font weight, or thickness.

Values

normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900, inherit

Default Value

normal

Useful For

All elements.

Inherited

Yes.

Notes

The browser uses a roman font for font-weight values from 100 to 400 and a bold font for values 500 to 900 (if a bold font is available on the phone).

Example
blockquote {font-weight: bold}

Displays the blockquote in boldface text.



font-size

Sets the size of a font, either in absolute terms or in relation surrounding content.

Values

xx-small, x-small, small, medium, large, x-large, xx-large, larger, smaller, em, ex, cm, mm, in, pt, pc, px, %, inherit

For more information, see Units of Measure, Percentage, and Keywords.

Default Value

medium

Useful For

All elements that contain text.

Inherited

Yes.

Notes

Relative values are relative to font size of the element that contains the current element.

Example
p {font-size: 12pt}

Displays the paragraph in 12-point type.

h1 {font-size: 150%}

Displays all first-level heads at 150%.



font

A shorthand property that sets the font family, font style, and font weight for text.

Values

See the values for font-family, font-style, and font-weight.

Default Value

See the individual font properties.

Useful For

All elements that contain text.

Inherited

Yes.

Notes

Because they share no common values, you can use the family, style, and weight values in any order.

Example
p {font: italic bold "Times New Roman", serif}

The paragraph is displayed in italics, bold, Times New Roman font. If Times New Roman is not available, another serif font is used.