Dam SamNang
Dam SamNang

Reputation: 347

How can I use a super-or-subscript tag in a HTML select option's display text?

I have a dropdown field like this:

<select>
  <option>1</option>
  <option>2</option>
  <option>3</option> 
</select>

Can I use a superscript tag <sup> like this?

<select>
 <option><sup>1</sup></option>
 <option><sup>2</sup></option>
 <option><sup>2</sup></option> 
</select>

Upvotes: 11

Views: 9012

Answers (2)

Samuel Liew
Samuel Liew

Reputation: 79073

Unicode superscript/subscript codes for numbers:

<p>Superscript numbers 0-9: &#x2070; &#185; &#178; &#179; &#x2074; &#x2075; &#x2076; &#x2077; &#x2078; &#x2079;</p>

<p>Subscript numbers 0-9: &#x2080; &#x2081; &#x2082; &#x2083; &#x2084; &#x2085; &#x2086; &#x2087; &#x2088; &#x2089;</p>

<select>
  <option>superscript &#x2070; &#185; &#178; &#179; &#x2074; &#x2075; &#x2076; &#x2077; &#x2078; &#x2079;</option>
  <option>subscript &#x2080; &#x2081; &#x2082; &#x2083; &#x2084; &#x2085; &#x2086; &#x2087; &#x2088; &#x2089;</option>
</select>

Upvotes: 0

Gurjot Bhatti
Gurjot Bhatti

Reputation: 977

You can't use another tag inside options tag. But you can do something like:

<select>
 <option>&sup1;</option>
 <option>&sup2;</option>
 <option>&sup3;</option> 
</select>

This &sub1, &sub2, &sub3 is only possible for 1, 2 and 3.

You can write other numbers using codes from here: Superscript Chart

Or you can use this website to get the unicodes of alphabets: Unicode Character Search

Upvotes: 23

Related Questions