How would you write out an exponent in HTML?

 

HTML actually provides a tag – called the superscript tag to make formatting of an exponent easy to display. Below we show what the HTML would look like if we wanted to write out 2 to the power of 10 with the proper formatting in HTML

Using the superscript tag for exponents in HTML

This is how you would write out 2 to the power 10 in HTML:


2<sup>10</sup> 

The result of using the <sup> tag:


210

Success! Pretty easy – although if asked this question in an interview, it’s something you would either know or not know.

Subscribe to our newsletter for more free interview questions.


Varoon Sahgal, Author of ProgrammerInterviewon