Web design and digital-business ideas grounded in real tasks.

MathML’s math-depth helps size nested mathematical notation

Mathematical notes beside a laptop
AI-generated photographic illustration; not documentary photography.

A superscript inside another superscript poses a small layout problem: it should look subordinate without becoming an arbitrary tiny fragment. MathML gives the browser a structure to work with, while CSS supplies properties that help express mathematical styling.

One of these is math-depth. According to MDN’s reference, it describes an element’s depth relative to the top of the formula and participates in font-size scaling when font-size: math applies. The browser’s default MathML stylesheet already uses that special font-size value for math content.

This is not a request to shrink every nested HTML element. A mathematical depth has meaning within formula layout; a deeply nested navigation menu does not become mathematical because it uses several wrappers.

Inspect a formula before overriding it

Start with a small test containing a base, a superscript and a nested superscript. Keep an untouched version beside any styled version. That gives you a reference when investigating why one part appears unexpectedly large or small.

MDN documents an explicit integer, relative changes such as add(1), and auto-add. The last depends on the inherited mathematical style rather than always adding a level. Copying it into a stylesheet without checking that context can therefore produce a surprise.

For a practical review, ask three questions:

  • Does the markup express the intended base and script relationships?
  • Are general site styles overriding the math content’s font settings?
  • Does the result remain legible when zoomed and viewed in the browsers your audience uses?

Keep accessibility testing alongside the visual check. A screenshot may show an attractive formula without revealing how its structure is exposed to assistive technology. Using MathML is a useful starting point, not evidence that every formula has automatically passed that test.

Adjust the smallest relevant rule, compare against the untouched example, and retain the semantic structure that explains what the notation means.