MathML Fractions

In MathML, fraction is created by using the <mfrac> tag. The numerator is taken as the first argument, followed by the denominator. This tag is used to display the basic algebra equations on web pages.

For example: To represent

Mathml Fractions 1

Use the following MathML code:

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

Attributes of Fraction element

There are some useful attributes used with <mfrac> element to control its appearance:

IndexAttributeDescription
1)linethicknessIt specifies the stroke width of the fraction bar. Its value should be a length measured in px, pt, em, etc.
2)numalignIt specifies the alignment of the numerator. It can be shifted left, right, or center.
3)denomalignIt specifies the alignment of the denominator. It can be shifted left, right, or center.
4)bevelledIt specifies whether the fraction should be displayed vertically or inline. It can be true or false.

Arranging complex fraction expressions

The above attributes are used to manually arrange the complex expressions.

For example: See the following complex fraction expression:

Mathml Fractions 2

Equivalent MathML code:

  1. <math xmlns=’http://www.w3.org/1998/Math/MathML’ display=’block’>  
  2.   <mfrac linethickness=’3px’>  
  3.     <mfrac bevelled=’true’>  
  4.       <mn>1</mn>  
  5.       <mi>x</mi>  
  6.     </mfrac>  
  7.     <mrow>  
  8.       <mi>y</mi>  
  9.       <mo></mo>  
  10.       <mn>2</mn>  
  11.     </mrow>  
  12.   </mfrac>  
  13. </math>  

Supporting Browsers:

Elementchrome browser Chromeie browser IEfirefox browser Firefox (Gecko)opera browser Operasafari browser Safari
<mfrac>Not SupportedNot SupportedSupportedNot SupportedOnly Basic Support

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *