# Scripts and limits

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

By convention, expressions that appear in a superscript position are typically shown in a reduced size, typically 71% of the font size of the base expression. You can use the following two CSS rules to implement this behavior in any MathML document:

```
msub > *:first-child{font-size: 100%}
msub > *{font-size: 71%}
```

The first rule applies to the first child of the msub element; that is, the base expression. The second rule then reduces the size of all children of the msub element by 71%. The first rule overrides the second. Hence, the net result of both rules is to reduce the size of the superscript, while keeping the font size of the base expression unchanged.

The following rules define how the contents of the msub element should be scaled in response to different settings of the mathsize attribute:

```
msub > *:first-child[mathsize="big"]{font-size: 125%}
msub > *[mathsize="big"]{font-size: 89%} /*(.71 times 1.25)*/
msub > *:first-child[mathsize="small"]{font-size: 80%}
msub > *[mathsize="small"]{font-size: 57%} /*(.71 times .80)*/
```

Similar rules can be defined for all the other script and limit elements, namely msup, msubsup, munder, mover, munderover, and mmultiscripts. For several MathML elements, the font size changes automatically as a consequence of a change in the value of the scriptlevel attribute. As discussed under General layout elements: Applying styles, this is an attribute of the mstyle element, and a default value for it is inherited from its environment by every presentation element.

The default value of scriptlevel for most elements is 0. However, some elements, such as those representing scripts and limits, increase the value of scriptlevel in some of their child elements. Each increase in the value of scriptlevel by one reduces the font size of the expression by a constant amount, which is determined by the value of the scriptsizemultiplier attribute. The default value of this attribute is 0.71. This means that an element for which scriptlevel="1" will display its contents at a font size 71% smaller than normal text. Similarly, if scriptlevel="2", the font size will be reduced by 0.71 times 0.71, which is 50%. This behavior can be implemented by the following style rules:

```
math *[scriptlevel="+1"] {font-size: 71%}
math *[scriptlevel="+2"] {font-size: 50%}
```

The following rules define the combined effect of changing the scriptlevel and mathsize attributes simultaneously:

```
math *[scriptlevel="+1"][mathsize="big"] {font-size: 89%} /*(.71 times 1.25)*/
math *[scriptlevel="+1"][mathsize="small"] {font-size: 57%} /*(.71 times .80)*/
math *[scriptlevel="+2"][mathsize="big"] {font-size: 62%} /*(.71 times .71 times 1.25)*/
math *[scriptlevel="+2"][mathsize="small"] {font-size: 40%} /*(.71 times .71 times .80)*/
```

The examples in this section illustrate how you can use CSS style rules to control the details of how a MathML expression is rendered. Any good MathML rendering application will, of course, already have some basic style rules of the type shown here built in and will apply them automatically when displaying any document that contains MathML. But if you want to change the default behavior and customize the display of mathematical formulas for special contexts, it’s useful to know how to control these rendering properties explicitly by means of a CSS stylesheet.

<< 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