Style attributes of token elements

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

There is a potential problem with using CSS stylesheets to control the appearance of Web documents that contain MathML. This is because the meaning carried by many mathematical symbols is closely related to the style in which they are rendered. For example, an italic letter might be used to indicate a variable or function name, a bold letter might indicate a vector, and a letter displayed in a Fraktur font might indicate a Lie algebra. As a result, style changes that are applied to a document purely for formatting reasons and inherited by the embedded MathML markup can change the meaning of the mathematical expression.

To avoid such unintended consequences of document-wide style changes, it is desirable to maintain a clean separation between the properties used to control the style of MathML expressions and the style of other content in an HTML document. To facilitate this goal, the MathML 2.0 specification introduces four new style attributes that can be used to set style properties in presentation markup (see the following table).

Table: New style attributes that can be used to set style properties in presentation markup.

Name Property Specified Allowed Value

mathbackground

Background color

#rgb | #rrggbb | html-color name

mathcolor

Text color

#rgb | #rrggbb | html-color name

mathsize

Font size

small | normal | big | number v-unit

mathvariant

Style variant

#rgb | #rrggbb | html-color name

Of these, the mathsize, mathcolor, and mathbackground attributes correspond closely to the font-size, color, and background-color property names in CSS. The mathvariant attribute is a composite of the CSS properties font-family, font-weight, and font-style. Some examples of CSS style rules involving these attributes are given in the sections that follow.

Size

The following rules define the mathsize attribute in terms of the CSS property font-size:

math *.[mathsize="small"] {font-size: 80%}
math *.[mathsize="normal"] {font-size: 100%}
math *.[mathsize="big"] {font-size: 125%}

Each rule, in effect, implements a particular value of the mathsize attribute by specifying its effect on the font size. The numbers 80% and 125% are typical values for the change in font size corresponding to mathsize="small" and mathsize="big", respectively.

Color and background

The following rules define the mathcolor attribute in terms of the CSS property color:

math *.[mathcolor="black"] {color: black}
math *.[mathcolor="white"] {color: white}
math *.[mathcolor="red"] {color: red}
math *.[mathcolor="blue"] {color: blue}
math *.[mathcolor="green"] {color: green}

The following rules define the mathbackground attribute in terms of the CSS property background-color:

math *.[mathbackground="black"] {background-color: black}
math *.[mathbackground ="white"] {background-color:white}
math *.[mathbackground ="red"] {background-color:red}

You can include similar style rules for the other HTML color keywords, such as gray, yellow, maroon, purple, teal, and aqua.

Font variants

The mathvariant attribute is defined in terms of its cumulative effect on the three CSS properties font-family, font-weight, and font-style. Here is a typical CSS rule for a particular value of mathvariant:

math *.[mathvariant="bold-italic"] {font-family: "Times", "Courier", serif; font-weight: bold; font-style: italic;}

This rule specifies the effect of setting mathvariant="sans-serif" on any MathML element:

math *.[mathvariant="sans-serif"] {font-family: "Helvetica", "Arial", sans-serif; font-weight: normal; font-style: normal;}

This rule uses the msbm font, which is part of the AMS font collection and includes double-struck characters:

math *.[mathvariant="double-struck"] {font-family: msbm; font-weight: normal; font-style: normal;}

This rule uses the eusb font, which is part of the AMS font collection and includes bold script characters:

math *.[mathvariant="bold-script"] {font-family: eusb; font-weight: bold; font-style: normal;}

This rule uses the eufb font, which is included in the AMS font collection and includes medium Fraktur characters:

math *.[mathvariant="fraktur"] {font-family: eufb; font-weight: bold; font-style: italic;}

Similar rules can be defined for all other values of the mathvariant attribute: normal, bold, italic, script, fraktur, bold-sans-serif, sans-serif-italic, and monospace.

   

<< back next >>

 

 

 

Tipp der data2type-Redaktion:
Zum Thema MathML bieten wir auch folgende Schulungen zur Vertiefung und professionellen Fortbildung an:

 

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