SuperscriptLineSpacing

Summary: How to fix line spacing of superscripts and subscripts
Version:
Prerequisites:
Status:
Maintainer:

Question

How can I fix line spacing of {^superscripts^} and {_subscripts_}?

Answer

The solution is to add the following to the style sheet:

#wikitext { line-height: 1.3em; }
#wikitext sub, #wikitext sup { line-height: 0; }

This can be done by adding the above lines to pub/css/local.css or by adding the following code into the config.php file:

    $HTMLStylesFmt[] = "
      #wikitext { line-height: 1.3em; }
      #wikitext sub, #wikitext sup { line-height: 0; }
    ";

Discussion

Normally, browsers display running prose with even line spacing. However, if the text happens to include superscript or subscript text, then most browsers render this with uneven line spacing. This looks ugly and distracts the reader from the content.

The fix is to modify the page's CSS rendering of <sup> and <sub> elements so that superscripts and subscripts do not change the current line's height, as given by the CSS statements above. This paragraph demonstrates how superscripts and subscripts are rendered when the above styles are included.

See Also

MarkupExtensions includes these styles settings.

Contributors