Skip to content
Related Articles

Related Articles

Improve Article

HTML5 MathML selection Attribute

  • Last Updated : 18 Nov, 2020

The MathML selection attribute in HTML5 is used to specify the child element that should be used for viewing. This value can be between 1 and the number of children of the element. The default value of this attribute is 1, which means that the first child element of all the options would be viewed by default. This attribute is accepted by the <maction> tag.

Syntax:

<element selection="index">

Attribute Values: This attribute has a single value as mentioned above and described below:

  • index: It holds the index of the child element to be viewed.

The example below illustrates the MathML selection attribute:

Example:



HTML




<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1 style="color:green">
            GeeksforGeeks
        </h1>
        <h3>HTML5 MathML selection Attribute</h3>
        <math>
  
            <!-- Selecting the first 
            option by default -->
            <maction actiontype="toggle" selection="1">
                <mfrac>
                    <mn>25</mn>
                    <mn>10</mn>
                </mfrac>
                <mfrac>
                    <mrow>
                        <mn>5</mn>
                        <mo>⋅</mo>
                        <mn>5</mn>
                    </mrow>
                    <mrow>
                        <mn>2</mn>
                        <mo>⋅</mo>
                        <mn>5</mn>
                    </mrow>
                </mfrac>
                <mfrac>
                    <mn>5</mn>
                    <mn>2</mn>
                </mfrac>
            </maction>
  
            <!-- Selecting the second
            option by default -->
            <maction actiontype="toggle" selection="2">
                <mfrac>
                    <mn>35</mn>
                    <mn>14</mn>
                </mfrac>
                <mfrac>
                    <mrow>
                        <mn>7</mn>
                        <mo>⋅</mo>
                        <mn>5</mn>
                    </mrow>
                    <mrow>
                        <mn>7</mn>
                        <mo>⋅</mo>
                        <mn>2</mn>
                    </mrow>
                </mfrac>
                <mfrac>
                    <mn>5</mn>
                    <mn>2</mn>
                </mfrac>
            </maction>
        </math>
  
        <p>Click the number</p>
  
    </center>
</body>
  
</html>

Output:

Supported Browsers: The browsers supported by HTML5 MathML selection attribute are listed below:

  • Firefox

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :