Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typing chemical formula using markdown

Tags:

html

markdown

I'm writing some material using Markdown on Mou.
And the chemical formula need to be used frequently.
For example, I would typing

 H<sub>2</sub>SO<sub>4</sub>        

Then, the sulfate acid can be represent as H2SO4 .
But I can't figure out how to represent the anion type formula in html.
The figure shows like this:

enter image description here

I try to typing

 SO<sub>4><sup>2-</sup></sub>   

It shows like this: SO42-

like image 207
Han Zhengzu Avatar asked Jun 24 '26 16:06

Han Zhengzu


2 Answers

You can use <sup> for the charge:

H<sub>2</sub>SO<sub>4</sub> + 2NaOH &rarr; 2H<sub>2</sub>O + Na<sup>+</sup> + SO<sub>4</sub><sup>2-</sup>

gives:

H2SO4 + 2NaOH → 2H2O + Na+ + SO42-

See this sample: https://jsfiddle.net/cp4n31qx/1/

This would even work without the CSS, I just used it to make it look better, here is a fiddle

HTML

<div>
  <h2>
  SO<sub>4</sub><sup>2-</sup>
  </h2>
</div>

CSS

sub {
  font-size:13px;
}

sup {
  font-size:13px;
  margin-left:-5px;
}
like image 38
Meers E. Chahine Avatar answered Jun 26 '26 06:06

Meers E. Chahine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!