MyInternships.in

HTML5 MathML

HTML5 MathML <mpadded> Tag

The <mpadded> element adjusts the space around its content without changing what is rendered. You can grow or shrink the reported width, height and depth, and shift the content, to fine-tune layout.


Definition and Usage

<mpadded> is a transparent wrapper: it draws its child normally but reports a modified bounding box to the surrounding formula. This is useful for nudging symbols, adding breathing room, or overlapping elements. Lengths may be absolute (px, em) or relative to the content.

Attributes

AttributeDescription
widthNew advance width of the content.
heightNew height above the baseline.
depthNew depth below the baseline.
lspaceSpace added to the left of the content.
voffsetVertical shift of the content (positive raises it).

Example

This adds extra left space and raises a term slightly to separate it from its neighbours.

Padding and shifting a term
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>MathML mpadded</title>
</head>
<body>
  <math display="block">
    <mrow>
      <mi>a</mi>
      <mo>+</mo>
      <mpadded lspace="1em" voffset="0.2em">
        <mi>b</mi>
      </mpadded>
    </mrow>
  </math>
</body>
</html>
💡

Set width="0" to make content overlap with what follows - a trick for stacking symbols. Use sparingly; heavy manual spacing can hurt readability.

Key Takeaways

  • <mpadded> changes the reported size and position of its content.
  • width, height, depth, lspace and voffset control the adjustments.
  • The content itself renders unchanged - only its bounding box moves.

Related HTML Topics

Keep learning with these closely related tutorials.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships