# Introduction

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

It is currently possible to view MathML in most major Web browsers. The MathML markup must be embedded in an HTML (or XHTML) document that is then displayed in the browser window. For the MathML markup to be interpreted and displayed as properly formatted mathematical notation, there are two main options.

The first option is to use a MathML-aware browser that can interpret and render MathML natively, without the need to install any additional components. Currently, the main browsers that fit this description are *Mozilla* 1.0, *Netscape* 7.0, and *Amaya*. The second option is to use Microsoft *IE* or *Netscape* in combination with suitable add-on software. The add-on software can be in the form of a plug-in or ActiveX control like IBM *techexplorer*, an *IE* Behavior like *MathPlayer*, or a tool for rendering MathML with Java applets, like *WebEQ*.

For an author of a Web document containing MathML, the main consideration is that the document should be viewable on as wide a variety of browsers and platforms as possible and using any of the standard add-ons available for rendering MathML. Unfortunately, the exact form of the MathML markup and the details of how it is embedded in the HTML document vary depending on the type of browser and add-on to be used.

Until recently, this lack of uniformity was a serious problem. It effectively meant that a MathML document had to be written specifically to target a particular type of browser or add-on. Once this was done, the same document would not be viewable on any other browser or even in the same browser using a different add-on. This problem has now been eliminated — at least for newer versions of the most popular browsers — thanks to an ingenious solution by David Carlisle, a member of the W3C and a co-editor of the MathML specification.

His solution involves the use of a special XSLT stylesheet called the **Universal MathML stylesheet**. This stylesheet can automatically transform the original source document and insert the specific markup needed to view the document in the environment available on the client machine. (For more information on XSLT and it how it can be used to transform MathML, see Using CSS with MathML.) The Universal MathML stylesheet makes it possible to create a single MathML document that can be displayed on various platforms using a variety of browsers and add-ons. All that’s required is for the browser being used to support XSLT transformations. Recent versions of the most popular browsers, including *IE* 5.0 and later or *Netscape* 6.1 and later, support these transformations. At the moment, however, XSLT-capable browsers are not widely deployed. Until they are, it will be necessary in the short term to support MathML display on older browsers as well.

This chapter is organized as follows: The Introduction describes the various compatibility problems that prevent a given MathML document from being displayed in a variety of environments. The Universal MathML stylesheet explains how the Universal MathML stylesheet provides an effective solution to these compatibility problems and gives instructions on authoring documents to take advantage of this stylesheet. MathML-enabled browsers and Add-on software review the features of the different browsers and add-ons available for displaying MathML. These sections include detailed information on the type of markup required to render MathML using a specific browser or add-on. This information is useful when you are authoring documents for older browsers, which do not support XSLT and therefore cannot use the Universal MathML stylesheet. Finally, Choosing a display method summarizes the strengths and limitations of the different display methods to help you choose between them.

## Compatibility issues

The various browsers and add-ons for displaying MathML have different requirements for how a document that contains MathML should be authored because each application requires a different set of answers to the following four questions:

- What is the
*Multipurpose Internet Mail Extensions*(MIME) type of the document? - What
*DOCTYPE declarations*does the document include? - How is the namespace of the MathML markup specified?
- Are any additional tags required to embed the MathML markup in the document?

In the following sections, we will briefly consider each of these issues. Although this information can be confusing, keep in mind that the Universal MathML stylesheet makes it unnecessary for you to know any of these details. If your main interest is in just authoring Web documents that contain MathML, you can skip ahead to the next page, which explains how to use the Universal MathML stylesheet.

### MIME Types

The MIME type of a file describes the type of content that the file contains. The browser uses this information to decide how the file should be processed. The MIME type is usually specified by the server (for files downloaded over the Web), but it can also be inferred from the file extension (for local files). For an XHTML+MathML document to be displayed by *IE*, the document's MIME type must be specified as text/html. On the other hand, for an XHTML+MathML document to be displayed by *Mozilla*, the document must have a MIME type of text/xml. This effectively means that the same document cannot be viewed in both *IE* and *Mozilla*.

One solution to this problem is to configure the Web server so it recognizes the type of browser that is requesting the document and then sets the MIME type accordingly. In other words, the server would send the same document with a MIME type of text/html to *IE* and text/xml to *Mozilla*. This requires you to know something about server programming, and you must have access to the server; both of these can be problematic for a potential author. A simpler solution is to include a reference to the Universal MathML stylesheet in the XHTML+MathML document. The stylesheet automatically specifies the MIME type for both *IE* and *Mozilla* correctly, using XSLT transformations on the client side.

### DOCTYPE Declarations

The second issue involves what DOCTYPE declarations should be included in the document. The DOCTYPE declaration specifies the DTD to which the document conforms (as explained under DTDs). *Mozilla* requires an XHTML+MathML document to include a DOCTYPE declaration that specifies the XHTML DTD. *IE* does not require a DOCTYPE declaration but will read and interpret one if it is included. This would imply that to create a document that is viewable in both *Mozilla* and *IE*, you should include a DTD declaration.

However, the problem is that *IE* will give an error if you attempt to view a document containing a DTD declaration to the real MathML DTD. This is because *IE* cannot handle named character entities corresponding to MathML characters that belong to plane 1 of Unicode. The solution to this is to use a modified XHTML+MathML DTD in which the entity declarations for all plane 1 characters have been replaced by alternative declarations that map all plane 1 characters to the private-use area of plane 0. (See MathML characters for more details.)

The modified DTD can be specified via the following declaration:

```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
```

You can use this declaration in a document to make it viewable in both *IE* and *Mozilla*. Of course, if you are using the Universal MathML stylesheet, this issue is irrelevant, since no DOCTYPE needs to be specified. The stylesheet automatically adds a suitable DOCTYPE declaration, if needed, based on the type of browser being used.

### Namespaces

The third issue is how the namespace of the MathML markup should be specified. Specifying the namespace is important so that you can distinguish the MathML element and attribute names from those in the containing document. One way to specify the namespace of MathML elements is to use the xmlns attribute on the outer math element, as shown below:

Alternatively, you can use a namespace prefix for each element and attribute, as shown below:

```
<m:math xmlns:m="http://www.w3.org/1998/Math/MathML">
<m:mrow>
<m:mi>x</m:mi><m:mo>+</m:mo><m:mn>1</m:mn>
</m:mrow>
< m:math>
```

This form is required when you are using *MathPlayer* or IBM *techexplorer* as a Behavior in *IE*. For more information on Behavior in *IE*, see Add-on software.

### Additional tags

The fourth issue to consider is whether any extra tags are required to embed the MathML markup in the HTML/XHTML document. In *Mozilla* and *Amaya*, the MathML markup can be included directly in the XHTML document; no additional tags are required. IBM *techexplorer* requires each instance of the MathML markup to be enclosed in an object or embed tag (depending on whether the MathML is to be viewed using *IE* or *Netscape*), and *WebEQ* requires an applet tag. *MathPlayer* does not require a tag around each MathML expression, but it requires an object tag to be inserted in the head tag of the HTML document. We shall see some examples of the markup required for specific browsers and add-ons under MathML-enabled browsers and Add-on software. But first, let’s look at the stylesheet that resolves most of these compatibility issues.

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