tags:

views:

44

answers:

2

Hi,

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!

+2  A: 

Well, you can specify position of sup relative to Sample Text's right border.

http://jsfiddle.net/a754h/

Nikita Rybak
Not very selectableable. MathML would be better, though it's not widely supported.
Ben Shelock
Ben, may I ask what do you mean by "not very selectableable"? You mean if someone wants to copy/paste the data?
Amati
+2  A: 

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.

CyberDude
Thanks, exactly what I needed! You may want to include your code here, in case anyone has the same problem, as the jsfiddle version may get deleted.
Amati
.supsub {position: absolute}.subscript {color: green; display:block; position:relative; left:2px; top: -5px}.superscript {color: red; display:block; position:relative; left:2px; top: -5px}Sample Text <span class='supsub'><sup class='superscript'>Sup</sup><sub class='subscript'>Sub</sub></span>
CyberDude
sorry about the formatting - not working in comments and I'd not add a new answer
CyberDude