Alan Hord
Alan Hord

Reputation: 111

HTML Input Button with Subscript

How can I format a typical Input with type="button" to display content text having a subscript format?

Example: O2

Upvotes: 0

Views: 1096

Answers (2)

Quentin
Quentin

Reputation: 943571

For that particular example you could just use Unicode code point U+2082:

    <input type="button" value="O₂">

… but in the general case the solution is stop using an input. HTML 4 introduced the <button> element to replace the submit, button and reset types.

<button> has two main advantages:

  • The value and display content can be different
  • The display content can include markup

<button type="button"> O<sub>2</sub> </button>

Upvotes: 1

Lal
Lal

Reputation: 14810

See this fiddle

You can use HTML <sub> to insert subscript. See the below given HTML

HTML

<button type="button">
  O<sub>2</sub>
</button>

Read more about <sub> in the docs

Upvotes: 1

Related Questions