You can inject a seperate style with the ::after
pseudo class.
CSS
button::after {
content: attr(data-superscript);
vertical-align: super;
}
HTML
<button data-superscript="8">2</button>
Using the attr()
property, you can dynamically change the superscript value based on the data-superscript
attribute.
Note that this is CSS3, and it's not compatible with all browsers.