(Excerpt from "The MathML Handbook" by Pavi Sandhu)
A set of style attributes controls the precise way in which the content of token elements is rendered. There are nine style attributes that all token elements accept. These attributes can be divided into two groups, depending on which version of MathML they were introduced in (see the two following tables).
Table: Style attributes introduced in MathML 2.0.
|Name||Property Specified||Allowed Value|
|mathbackground||Background color||#rgb | #rrggbb | html-colorname|
|mathcolor||Text color||#rgb | #rrggbb | html-colorname|
|mathsize||Font size||small | normal | big | number v-unit|
|mathvariant||Style variant||normal | bold | italic | script | bold-script | double-struck | fraktur | bold-fraktur | sans-serif | bold-sans-serif | sans-serif-italic | monospace|
html-color-name refers to one of the named color keywords defined in HTML 4 (that is, aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow).
Table: Style attributes introduced in MathML 1.0.
|Name||Property Specified||Allowed Value|
|color||Text color||#rgb | #rrggbb | html-colorname|
|fontfamily||Font family||string | css-fontfamily|
|fontsize||Font size||number v-unit|
|fontstyle||Font style||normal | italic|
|fontweight||Font weight||normal | bold|
The use of the second set of attributes is deprecated in MathML 2.0 since they conflict with properties of the same name defined in CSS! Having the same attribute names in MathML and CSS can lead to problems. For example, the meaning of an equation may be altered by system-wide style changes applied using a CSS stylesheet. These attributes are still supported for backward compatibility and because they provide a simple way to directly specify common style properties. For some examples of how these attributes can be used in a CSS stylesheet, to control the rendering of MathML equations, see CSS primer.
There is some overlap between the style attributes introduced in MathML 2.0 and the older ones from MathML 1.0. For example, you can specify the color of an equation using either the color or mathcolor attributes. Similarly, you can cause an equation to be displayed in bold font using either fontweight or mathvariant. In case of a conflict between the new attributes (from MathML 2.0) and the deprecated attributes (MathML 1.0), the former take precedence. For example, the following expression should render in a bold font.
<mi fontweight="normal" mathvariant="bold">ABC</mi>
The following expression should render in an italic sans-serif font.
<mi fontweight='bold' mathvariant='sans-serif-italic'>ABC</mi>
In practice, most MathML expressions are likely to be embedded in another XML data format such as XHTML. In such cases, it is desirable for the displayed equations to have the same style attributes as the surrounding text, so that the font styles and sizes, for example, are compatible with the environment. For this reason, the default values of most of the above style attributes are inherited from the environment.
The meaning and usage of most of the style attributes listed above are evident from their names. However, the mathvariant attribute requires some further explanation. This attribute specifies that a character should be displayed in a particular font variant, such as Fraktur, Bold, Italic, Script, Bold-Script, Double-struck, and so on. In mathematical notation, each of these style variants often has a specific meaning associated with it. For example, an italic g might indicate a function name, a bold g might indicate a vector, and a Fraktur g might indicate a Lie algebra. Hence, you should not use the mathvariant style attribute to specify styles unless the meaning implied by that style is specifically intended.
The MathML DTD includes a set of character entities that directly represent styled characters described by different values of the mathvariant attribute. However, these characters are in plane 1 of Unicode and plane 1 characters cannot be displayed in current browsers. Hence, in many cases it is preferable to use the mathvariant attribute in combination with a plane 0 character instead of the corresponding plane 1 character. (The meaning of plane 0 and plane 1 characters was explained under MathML characters.)
For example, if you want to include a Fraktur g in a mathematical expression, you can do so using the character entity reference to the plane 1 Unicode character for this symbol, as shown here:
Alternatively, you can use the mathvariant attribute applied to the ordinary letter g, as shown below:
The fact that the same character can be represented in two different ways can cause problems for applications where the semantic meaning of the markup is important, such as when you are searching or indexing mathematical content. To avoid such problems, the MathML specification requires that processing applications treat plane 0 characters with the mathvariant attribute specified as equivalent to the corresponding plane 1 characters.
|<< back||next >>|
Copyright © CHARLES RIVER MEDIA, INC., Massachusetts (USA) 2003
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "The MathML Handbook" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.
CHARLES RIVER MEDIA, INC., 20 Downer Avenue, Suite 3, Hingham, Massachusetts 02043, United States of America