Developer Reference
Square Root Symbol in HTML — Entity, Unicode & CSS Methods
Three Ways to Write the Square Root Symbol in HTML
The square root symbol (√, Unicode U+221A, named "SQUARE ROOT") has full support across all HTML versions and browsers. There are three standard encoding approaches, and choosing between them mostly comes down to readability preference — they all produce identical output in every modern browser.
| Method | Code | Output | Best for |
|---|---|---|---|
| Named entity | √ | √ | HTML templates, most readable |
| Decimal entity | √ | √ | When named entities are disabled |
| Hex entity | √ | √ | When you prefer hex references |
| Direct UTF-8 | √ (pasted) | √ | UTF-8 encoded files |
Named Entity: √
The named entity √ is the most human-readable option. It comes from the word "radical" — the mathematical term for the root symbol. Any HTML file will render it correctly, from HTML 4 through HTML5.
<!-- These are all identical in output --> <p>The formula is: <strong>√2</strong> ≈ 1.414</p> <!-- Using the entity in a math context --> <p>Hypotenuse = √(a<sup>2</sup> + b<sup>2</sup>)</p>
Note that √ renders the bare radical symbol only — it does not draw the horizontal overline (vinculum) that appears in typeset math. For a complete radical with overline, use MathML or a math library such as MathJax (covered below).
Decimal & Hex Entities: √ and √
The decimal entity √ and hex entity √ both reference the same Unicode code point, U+221A. Use whichever matches your team's convention. Hex is sometimes preferred because it maps directly to the Unicode value; decimal is slightly easier to read for non-specialists.
<!-- Decimal entity --> <span>√144 = 12</span> <!-- Hex entity (U+221A = 0x221A = decimal 8730) --> <span>√144 = 12</span>
Using the Square Root Symbol in CSS
In CSS content property (used to insert characters with ::before or ::after pseudo-elements), the Unicode escape syntax is different — no ampersand, no semicolon, just a backslash followed by the hex code point.
/* CSS content property uses backslash + hex code point */ .radical::before { content: '\221A'; } /* Styled square root label */ .math-label::before { content: '\221A'; font-family: 'Georgia', serif; font-size: 1.2em; color: #333; margin-right: 2px; }
CSS vs HTML encoding: In CSS, \221A (no leading zero needed for 4-digit codes). In HTML, √. In JavaScript strings, '√' or "√". Each context has its own escape syntax — they are not interchangeable.
Square Root Symbol in JavaScript
When building HTML strings dynamically with JavaScript, you have three choices: the Unicode escape, the literal character, or the HTML entity (which the browser will parse when the string is set as innerHTML).
// 1. Unicode escape in a string literal const radical = '√'; document.getElementById('result').textContent = radical + '2 ≈ 1.414'; // 2. Direct character (file must be saved as UTF-8) const radical2 = '√'; // 3. Entity in innerHTML (browser parses it) element.innerHTML = '√2 ≈ 1.414'; // 4. DOM text node (safest — no XSS risk) const span = document.createElement('span'); span.textContent = '√' + '2'; document.body.appendChild(span);
Best practice: When inserting into textContent or innerText, use the Unicode escape '√' — the browser treats it as a plain character, no HTML parsing needed, and there is no XSS risk. Reserve innerHTML for cases where you also need markup around the symbol.
Proper Math Markup with MathML and MathJax
For typeset mathematics with the full radical notation (the symbol plus a horizontal bar over the radicand), HTML entities alone are not enough. The √ entity gives you just the symbol — no overline. For proper rendered math, you have two main options.
MathML (built-in browser math)
MathML is part of the HTML5 spec and supported natively in modern browsers (Chrome 109+, Firefox, Safari). No library needed:
<!-- Square root of 2 with overline --> <math> <msqrt> <mn>2</mn> </msqrt> </math> <!-- Square root of x+1 --> <math> <msqrt> <mi>x</mi> <mo>+</mo> <mn>1</mn> </msqrt> </math>
MathJax (LaTeX syntax in HTML)
If you prefer LaTeX notation, MathJax renders it beautifully in any browser. The LaTeX command for square root is \sqrt{}:
<!-- Add MathJax to your page --> <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <!-- Inline math: $\sqrt{2}$ --> <p>The value of $\sqrt{2}$ is approximately 1.414.</p> <!-- Display math (centered, larger) --> <p>$$c = \sqrt{a^2 + b^2}$$</p>
Quick Reference: All Encodings
| Context | Syntax | Example |
|---|---|---|
| HTML entity (named) | √ | √2 |
| HTML entity (decimal) | √ | √2 |
| HTML entity (hex) | √ | √2 |
| CSS content | \221A | content: '\221A' |
| JavaScript string | √ | '√' + '2' |
| JavaScript (ES6+) | \u{221A} | '\u{221A}' |
| URL encoding | %E2%88%9A | ?q=%E2%88%9A |
| Python string | √ | '√' |
Frequently Asked Questions
What is the HTML entity for the square root symbol?
The named HTML entity is √. The decimal version is √ and the hex version is √. All three produce the same √ character in every modern browser. The name "radic" comes from "radical," the mathematical term for the root symbol.
Why doesn't √ show a line over the number?
The √ HTML entity renders the bare √ character — the hook shape — but does not draw the horizontal vinculum (overline) that typeset math shows over the radicand. For a complete radical with overline, use MathML's <msqrt> element or a library like MathJax with \sqrt{} LaTeX syntax.
How do I type the square root symbol in a CSS content property?
In CSS, use the backslash escape: content: '\221A'. This is the hex code point without the "U+" prefix. Do NOT use the HTML entity syntax (√ or √) inside CSS — those only work in HTML. The CSS escape uses a backslash, not an ampersand.
Is √ supported in all browsers?
Yes. √ has been supported since HTML 4 (1997) and works in every browser in current use — Chrome, Firefox, Safari, Edge, and their mobile counterparts. It is one of the oldest named entities in the HTML spec. You do not need any polyfill or fallback.
Should I use √ or just paste the √ character directly into HTML?
Both work fine if your file is saved as UTF-8 (which all modern editors default to). The entity form (√) is slightly safer in older build pipelines that might mangle non-ASCII characters during concatenation or minification. The direct character is more readable in source. For any file you fully control with a UTF-8 declaration, pasting √ directly is perfectly valid.