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!
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/
Here's a clean solution. Create two CSS classes:
You might already have the "nobr" class as a <nobr> replacement. Now to express the molecular formula for sulfate, use the "supsub" class as follows:
That is, enclose your superscript/subscript within the "supsub" class, and put a <br /> between them. If you like your superscripts/subscripts a bit larger or smaller, then adjust the font size and then tinker with the vertical-align and line-height. The -9em in the margin setting is to keep the superscripts/subscripts from adding to the height of the line containing them; any big value will do.
I'm no CSS guru but you could try something along the lines of http://jsfiddle.net/TKxv8/1/
There are a lot of hardcoded values and the effects on other elements around may only be found afterwards but it's a good place to start.
Well, you can specify position of
sup
relative toSample Text
's right border.http://jsfiddle.net/a754h/