Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Displaying a square root with HTML

DZone's Guide to

Displaying a square root with HTML

· Web Dev Zone ·
Free Resource

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

This post shows two ways of displaying a square root with HTML.

Pure HTML for older browsers. The following HTML source

    &radic;<span style="text-decoration: overline">2</span>
is displayed as
2
Not all browsers display the above equally well, but it is always readable.

MathML for newer browsers. The following HTML source

    <math><msqrt><mi>2</mi></msqrt></math>
is displayed as
2
With MathML being part of HTML5, all modern browsers support MathML. Which is a god-given for those of us who remember the HTML documents that were generated from LaTeX source files by converting formulae to bitmap graphics.

Related reading:

 

From http://www.2ality.com/2011/10/html-square-root.html

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}