MyInternships.in

HTML5 MathML

HTML5 MathML align Attribute

The align attribute controls vertical alignment. On an <mtable> it sets how the whole table lines up with surrounding math; on scripts such as <mover> it can adjust positioning. Values include top, bottom, center, baseline and axis.


Definition and Usage

Use align to raise or lower an element relative to the baseline of the formula around it. On an <mtable>, align="axis" centres the table on the math axis so it sits neatly beside operators; other values move it up or down.

Values

ValueEffect
topAligns the top of the element to the baseline.
bottomAligns the bottom to the baseline.
centerCentres the element vertically.
baselineAligns the element's baseline.
axisCentres on the math axis (default for tables).

Example

Aligning a matrix beside a label
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>MathML align attribute</title>
</head>
<body>
  <math display="block">
    <mrow>
      <mi>A</mi><mo>=</mo>
      <mo>(</mo>
      <mtable align="axis">
        <mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr>
        <mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr>
      </mtable>
      <mo>)</mo>
    </mrow>
  </math>
</body>
</html>
ℹ️

align interacts with rowalign and columnalign on tables. Support for some values is limited outside the MathML Core defaults.

Key Takeaways

  • align controls vertical positioning relative to the baseline.
  • On tables, axis centres the matrix on the math axis.
  • Combine with rowalign and columnalign for full control.

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