How would you write out a logarithm base 2 in HTML? In other words, what tags would you use for the formatting?

 

HTML actually provides a tag – called the subscript tag to make the base 2 formatting of a logarithm easy to display (or any other formatting requiring a subscript). Below we show what the HTML would look like if we wanted to write out log base 2 of 1000.

Using the subscript tag for logarithms in HTML

This is how you would write out the log base 2 of 1000 in HTML:


log<sub>2</sub> 1000

The result of using the <sub> tag:


log2 1000

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

Hiring? Job Hunting? Post a JOB or your RESUME on our JOB BOARD >>

Subscribe to our newsletter for more free interview questions.