Permitted Context: %math
Content Model: %math

The SUB and SUP elements are used for subscripts and superscripts respectively, and are preferably rendered in reduced font. For integral and related signs the SUB and SUP elements are used for the lower and upper limits, for instance:

   &sum;<sub>n = 0</sub><sup>&inf;</sup>

which renders to (within limits of ascii art):

   n = 0

The SGML SHORTREF characters "_" and "^" can be used as abbreviations. The above example is abbreviated to:

    &sum;_n = 0_^&inf;^

Need to give entity names for when you need the _ and ^ characters!

You have to revert to the full form of the tags when superscripting a superscript or subscripting a subscript, as in:

    X<sub>a<sub>i</sub></sub>  which is  X    

You can also use superscripts to place expressions or words over binary operators, for instance in the following chemical reaction:

    4LiH + AlCl_3_ &rarr;^ether^ LiAlH_4_ + 3LiCl

which renders as:

     4LiH + AlCl  ------>  LiAlH  +  3LiCl
         3                      4

The superscript is centered over the operator, and when feasible the operator stretched to match the width of the superscript.

Note: Dont' use the shortrefs for SUB and SUP in normal text - they only work within MATH elements!

Placement of subscripts and superscripts

Some times you will want to place superscripts to the left of a term. The simplest way to do this is with shortrefs, e.g.

    _4_^9^Be + _2^4^He &rarr; _6_^12^C + _0_^1^n

which renders to (within limits of ascii art):

     9      4        12    1
      Be +   He  -->   C +  n
     4      2         6    0

Subscripts and superscripts immediately before a term are rendered to the left of the term, where as subscripts and superscripts immediately after a term are rendered on its right. Opportunities for confusion arise when scripts for a preceding term are followed by scripts for another term. The simplest solution is to use whitespace to disambiguate the situation. For instance:

                      b                           b
    X_a_ ^b^Y  is  X   Y   while  X_a_^b^Y   is  X   Y
                    a                             a
                                           a  b
    but both X^a^ ^b^Y and X^a^^b^Y  are  X    Y   

The last case is disambiguated because the two superscript elements can't both apply to the preceding term, as they can't both be drawn in the same position. The same would apply to two subscript elements. If in any doubt, its wise to insert a space to make your meaning clear! If you prefer, you can use curly brackets, as in: {X_a_}{^b^Y}. These brackets are shortrefs for the BOX element and don't appear when the expression is finally rendered.

The same rules apply when you use the full form of the SUB and SUP elements. The ALIGN attribute can be used to override the default position to render the script, which is normally taken from whether the script element precedes or follows the term to which it applies. For instance:

    X<sub align=right>a</sub> <sup align=left>b</sup>Y
    X<sub align=right>a</sub>Y<sup align=left>b</sup>
    both render to    X    Y

    while  X<sub align=right>a</sub><sup align=left>b</sup>Y

    renders to       X   Y

In the last case, the SUP element act as a prefix superscript to X as there isn't a delimiter between it and the preceding SUB element. If in doubt, you should use brackets or whitespace to disambiguate the binding.

Permitted Attributes

The ID, LANG and CLASS attributes for SUB and SUP are not used within MATH elements.

Subscripts and superscripts are normally placed to the right of the term to which they apply, while limits are normally placed above (or below) the symbol they apply to. The ALIGN attribute can be used to override the default positioning.

The script (or limit) is placed to the left of the term.
The script is centered on the term and placed below it for subscripts, and above it (for superscipts).
The scripts are placed to the right of the term.

For example, you can force limits on integral signs to appear on the right rather than centered on the integral sign:

&int;<sub align=right>0</sub><sup align=right>&inf;</sup>

Note: The ALIGN attribute should be ignored by user agents for the SUB and SUP elements except within MATH elements.