Français

<msqrt>

Write a square root or nth root

  • MathML
  • accessibility
  • semantics

<msqrt> + <mroot> — Roots

<msqrt> displays a square root. <mroot> displays an nth root with two children: the base (radicand) and the root index.

When to use it

You want to display a square root in a formula: <msqrt> takes one or more children that form the radicand. You want a cube root or nth root: <mroot> takes exactly two children, the radicand then the index.

What you gain

Accessibility: screen readers announce "square root of" or "nth root of" with the structured content. No guessing about what is under the radical.

Code example

<math display="block">
  <mrow>
    <mi>d</mi>
    <mo>=</mo>
    <msqrt>
      <mrow>
        <msup><mi>x</mi><mn>2</mn></msup>
        <mo>+</mo>
        <msup><mi>y</mi><mn>2</mn></msup>
      </mrow>
    </msqrt>
  </mrow>
</math>
 
<!-- Cube root -->
<math>
  <mroot>
    <mn>27</mn>
    <mn>3</mn>
  </mroot>
</math>

Further reading