Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

subscript and superscript for the same element

Tags:

html

css

xhtml

Is there any way to add both subscript and and superscript to the same element? If I do

Sample Text<sub>Sub</sub><sup>Sup</sup>

the superscript appears after the subscript. One I idea I had is to do something like:

<table>
    <tr>
        <td rowspan='2' valign='center'>Sample Text</td>
        <td>Sup</td>
    </tr>
    <tr>
        <td>Sub</td>
    </tr>
</table>

It seems to do the job but is quite ugly. Any better ideas?

Thanks!

like image 717
Amati Avatar asked Sep 18 '10 18:09

Amati


People also ask

Can we write in superscript and subscript?

Select the text or number that you want. For superscript, press Ctrl, Shift, and the Plus sign (+) at the same time. For subscript, press Ctrl and the Equal sign (=) at the same time. (Do not press Shift.)

How do you subscript and superscript at the same time in LaTeX?

Overleaf - LaTeX: Mathematics in LaTeX To produce text in superscript, use a caret followed by the text you want in superscript in curly brackets. To write text as a subscript, use an underscore followed by the text in curly brackets. The symbol "&" on its own is used as part of a code in LaTeX.


1 Answers

This one is similar to CyberDudes approach, additionally it indents the following text depending on the width of sub and sup:

http://jsfiddle.net/jwFec/1/

Some text <span class="supsub"><sup>sup</sup><sub>sub</sub></span> followed by other text.<br />

<style>
.supsub {
    display: inline-block;
}

.supsub sup,
.supsub sub {
    position: relative;
    display: block;
    font-size: .5em;
    line-height: 1.2;
}

.supsub sub {
    top: .3em;
}
</style>
like image 139
Thomas Avatar answered Nov 15 '22 22:11

Thomas