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
Use the following MathML code:
- <math xmlns=’http://www.w3.org/1998/Math/MathML’ display=’block’>
- <mfrac>
- <mn>1</mn>
- <mi>x</mi>
- </mfrac>
- </math>
Attributes of Fraction element
There are some useful attributes used with <mfrac> element to control its appearance:
Index | Attribute | Description |
---|---|---|
1) | linethickness | It specifies the stroke width of the fraction bar. Its value should be a length measured in px, pt, em, etc. |
2) | numalign | It specifies the alignment of the numerator. It can be shifted left, right, or center. |
3) | denomalign | It specifies the alignment of the denominator. It can be shifted left, right, or center. |
4) | bevelled | It 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:
Equivalent MathML code:
- <math xmlns=’http://www.w3.org/1998/Math/MathML’ display=’block’>
- <mfrac linethickness=’3px’>
- <mfrac bevelled=’true’>
- <mn>1</mn>
- <mi>x</mi>
- </mfrac>
- <mrow>
- <mi>y</mi>
- <mo>−</mo>
- <mn>2</mn>
- </mrow>
- </mfrac>
- </math>
Supporting Browsers:
Element | Chrome | IE | Firefox (Gecko) | Opera | Safari |
<mfrac> | Not Supported | Not Supported | Supported | Not Supported | Only Basic Support |
Leave a Reply