0

I was looking over some repo that was from a bootcamp to learn full stack development. On the jquery lesson, they were asked to build a calculator. There was a part of the html that had some weird variable where the text content should be. I wanna know what the purpose of this is and how and when I should use it? Perhaps it's nothing at all and I am just overthinking it. I am talking about the ÷ and × etc...

          <div class="card-body">
            <button id="button-1" class="btn btn-primary number" value="1"><span>1</span></button>
            <button id="button-2" class="btn btn-primary number" value="2"><span>2</span></button>
            <button id="button-3" class="btn btn-primary number" value="3"><span>3</span></button>
            <button id="button-plus" class="btn btn-danger operator" value="plus"><span>+</span></button>
            <br><br>
            <button id="button-4" class="btn btn-primary number" value="4"><span>4</span></button>
            <button id="button-5" class="btn btn-primary number" value="5"><span>5</span></button>
            <button id="button-6" class="btn btn-primary number" value="6"><span>6</span></button>
            <button id="button-minus" class="btn btn-danger operator" value="minus"><span>&minus;</span></button>
            <br><br>
            <button id="button-7" class="btn btn-primary number" value="7"><span>7</span></button>
            <button id="button-8" class="btn btn-primary number" value="8"><span>8</span></button>
            <button id="button-9" class="btn btn-primary number" value="9"><span>9</span></button>
            <button id="button-multiply" class="btn btn-danger operator" value="times"><span>&times;</span></button>
            <br><br>
            <button id="button-0" class="btn btn-primary number" value="0"><span>0</span></button>
            <button id="button-divide" class="btn btn-danger operator" value="divide"><span>&divide;</span></button>
            <button id="button-power" class="btn btn-danger operator" value="power"><span>^</span></button>
            <button id="button-equal" class="btn btn-success equal" value="equals"><span>=</span></button>
            <br><br>
            <button id="button-clear" class="btn btn-dark clear" value="clear"><span>clear</span></button>
          </div>
        </div>
      </div>

2 Answers2

1

These are called HTML entities. They all start with "&" and end in ";" and represent a certain special character. There are some reserved characters in HTML such as:

< &lt;
> &gt;
" &quot;
' &apos;

So you might want to display "<something>" in your document, and if you don't replace the less than and greater than symbols, it will treat "<something>" as an opening tag. These don't seem necessary in your case, and you should be able to simply use the normal characters because the ones you are using are not reserved.

You can simply copy and paste these into the HTML: × ÷ -

More info here: https://www.w3schools.com/html/html_entities.asp

65536
  • 106
  • 7
0

If you are referring to &times, this is a HTML entity.

This syntax is needed for characters that are reserved in HTML.

A reference list is here: https://www.w3schools.com/charsets/ref_html_entities_4.asp

You can learn more about HTML entities here: https://www.w3schools.com/html/html_entities.asp

John Hanlon
  • 462
  • 3
  • 10
  • 22