Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

math-depth — mathematical nesting level

The math-depth property sets the mathematical level used to compute font-size: math; it does not measure DOM tree depth.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

math-depth: auto-add | add(<integer>) | <integer>;

math-depth applies to all elements, is inherited, and initially equals 0. Its computed value is an integer.

<integer> sets an absolute level; add(<integer>) adds an integer, including a negative one, to the inherited level. auto-add adds 1 only when inherited math-style is compact; otherwise it preserves the inherited level. The parent's style matters, not the locally specified style.

Scaling requires font-size: math and depends on the font, so do not assume a fixed pixel conversion. The example checks levels rather than sizes.

Examples

<!doctype html>
<meta charset="utf-8">
<title>math-depth</title>
<style>
  #parent { math-depth: 2; math-style: compact; }
  #relative { math-depth: add(-1); }
  #automatic { math-depth: auto-add; }
</style>
<div id="parent">
  <span id="relative">A</span>
  <span id="automatic">B</span>
</div>
<pre id="output"></pre>
<script>
  const ids = ['parent', 'relative', 'automatic'];
  document.getElementById('output').textContent = ids.map(id =>
    getComputedStyle(document.getElementById(id))
      .getPropertyValue('math-depth').trim()
  ).join(', ');
</script>

Result

2, 1, 3

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources