How to make subscript and superscript in Dash

I want to write H2 with an underscript. I have try:

html.Div([‘H_2’])
html.Div(r’H_2’])
html.Div(r’$H_2$’])
html.Div('H2<\sub>])

But nothing seems to work. What Am I missing?

Thanks

Michaël

Hi @Mlevesque

You can use the html.Sub() and the html.Sup() for subscripts and superscripts:

html.Div(["H", html.Sub(2), "H", html.Sup(2)])

image

1 Like

Thanks It work very Well!

Hi, I want to show subscript and superscript (Fe3O4Reduction) in following component label.

dbc.InputGroupText(‘Fe’, 2 O 3 Reduction’, className=“inputgrouptitle”, style={‘width’:‘20%’} )

The problem is that the subscript and superscripts shows up correctly but the space between the subscript and the next word is not shown. In the above example, instead of showing ‘Fe3O4 Reduction’, ‘Fe3O4Reduction’ is shown.

How to insert the space between a ‘4’ and ‘Reduction’?