Search code examples
csshtmlbuttonsqrt

How to get the sqrt symbol in a buttons value?


im trying to get the sqrt symbol to display inside my button. I cant seem to get it to work. Here is my button code

<input type="button" id="sqrt" value="sqrt" onclick="insert function here">

We the value, i need to get the sqrt symbol to show up and I cant seem to figure out how.


Solution

  • If you need to find a specific symbol you can refer to W3's Character Entity Reference Chart.

    The Square Root (√) symbol can be displayed using one of the following:

    &radic;
    &Sqrt;
    &#x0221A;
    &#8730;
    

    For example:

    <input type="button" value="&radic;" />       <!-- or... -->
    <input type="button" value="&Sqrt;" />        <!-- or... -->
    <input type="button" value="&#x0221A;" />     <!-- or... -->
    <input type="button" value="&#8730;" />
    

    Personally I'd opt for either &#x0221A; or &#8730; as these directly reference the symbol's Unicode ID. A browser may not necessarily have any mapping defined for &radic; or &Sqrt;.

    JSFiddle demo.