MathML Superscripts

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

MathML Superscripts

MathML superscript is created with the tag. You have to place the base inside the tag, followed by the superscript.

Example

If you want to write x2, use the following MathML code:

Equivalent MathML code:

  1. <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'>  
  2.   <msup>  
  3.     <mi>x</mi>  
  4.     <mn>2</mn>  
  5.   </msup>  
  6. </math> 

MathML element <msup> acts more like a function than a normal HTML markup tag. In the above MathML code, the base and the superscript can be thought of as two "arguments" passed to the <msup> "function." Both arguments need to be a single MathML element (e.g., <mi> or <mn>). It is fine for working with atomic values like x and 2, but things get more complicated once we start working with compound expressions.


Grouping Sub-Expressions

Group of sub expression is used to include more than one element. It cannot be passed directly into <msup>. Instead, you will have to use <mrow> tag to group the expression, as shown below.

For example: If you want to write e2x+1, use the following MathML code:

Equivalent MathML code:

  1.  <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'>    
  2.   <msup>  
  3.     <mi>e</mi>  
  4.     <mrow>  
  5.       <mn>2</mn>  
  6.       <mi>x</mi>  
  7.       <mo>+</mo>  
  8.       <mn>1</mn>  
  9.     </mrow>  
  10.   </msup>  
  11. </math

It will display the expression like this:

Mathml Superscript 1

To create a complex base expression, you have to wrap the superscript argument in an <mrow> element.

For example: If you want to write an expression (5x ? 3y)2, use the following MathML code:

Equivalent MathMl code:

  1. <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'>  
  2.   <msup>  
  3.     <mrow>  
  4.       <mo>(</mo>  
  5.         <mrow>  
  6.           <mrow><mn>5</mn><mi>x</mi></mrow>  
  7.           <mo>-</mo>  
  8.           <mrow><mn>3</mn><mi>y</mi></mrow>  
  9.         </mrow>  
  10.       <mo>)</mo>  
  11.     </mrow>  
  12.     <mn>2</mn>  
  13.   </msup>  
  14. </math>  

Supporting Browsers:

Element chrome browser Chrome ie browser IE firefox browser Firefox (Gecko) opera browser Opera safari browser Safari
<msup> Not Supported Not Supported Supported Not Supported Only Basic Support