If you want to add superscript or subscript in html, for example on your website, you will need to add the correct format into your code. We will show you how it works.
Superscript in html
To add superscript text in html you will need to use the <sup> tag, which defines the superscript text in coding.
- <!DOCTYPE html>
- <html>
- <body>
- <p>text <sup>superscript text</sup></p>
- </body>
- </html>
Your text will then appear like this: textsuperscript text
Subscript in html
To add subscript text in html you will need to use the <sub> tag, which defines the subscript text in coding.
- <!DOCTYPE html>
- <html>
- <body>
- <p>text <sub>subscript text</sub></p>
- </body>
- </html>
Your text will then appear like this: textsubscript text