Question

i am trying to apply a subscript for an alphabet in option tag of an html select combo box. For numbers i found a solution by substituting it with some unicodes, but nothing found for alphabets. i have already tried <option>sample<sub>e</sub></option>. Is there any possible way for this.

Was it helpful?

Solution

Since option element content is interpreted as plain text, you cannot use markup there. You might consider using other markup for a menu, replacing a select element with a set of radio buttons (or, depending on desired logic, checkboxes), possibly styled to resemble a dropdown list, or something.

Using option, you can still use any Unicode characters, in principle. But font support imposes serious limitations. Even subscript digits aren’t safe. There are subscript letters too in Unicode, but they do not constitute a systematic set, since they have been defined in order to support certain phonetic notations, not subscripting in general. Moreover, they are in Plane 1, e.g. U+1D64 LATIN SUBSCRIPT SMALL LETTER U “ᵤ”, and very few fonts contain Plane 1 characters.

OTHER TIPS

As far as I know it's not possible. I also tried googling just to confirm, and there are a few results suggesting that I am correct

Normally you cannot style the list in the select element (as well as you cannot style date and time inputs widgets).

Instead you could use JavaScript to substitute your select with custom code. More about that can be found in the book "designing with progressive enhancement" by The Filament group, on their website or in google.

As per my knowledge, it's not possible to to subscript or superscript the options in select element directly. Dynamically manipulating text style inside option elements by javascript looks one option to me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top