pub struct Math;Expand description
The <math> element - embeds MathML (Mathematical Markup Language) content.
§Purpose
The <math> element is the top-level element for MathML content, used to embed
mathematical expressions and equations in HTML documents. MathML provides semantic
markup for mathematical notation, enabling proper rendering, accessibility, and
computational manipulation of mathematical expressions.
§Content Categories
- Flow Content
- Phrasing Content
- Embedded Content
- Palpable Content
§Permitted Content Model
MathMLelements (followsMathMLspecification, not HTML)
§Common Use Cases
- Displaying mathematical equations and formulas
- Scientific and technical documentation
- Educational materials with math content
- Research papers and academic publications
- Interactive math applications
§Key Attributes
display: “block” or “inline” (controls display mode)xmlns: XML namespace (usually"http://www.w3.org/1998/Math/MathML")- Plus all MathML-specific attributes
§Example
<!-- Inline math: Pythagorean theorem -->
<p>The Pythagorean theorem states that
<math>
<msup><mi>a</mi><mn>2</mn></msup>
<mo>+</mo>
<msup><mi>b</mi><mn>2</mn></msup>
<mo>=</mo>
<msup><mi>c</mi><mn>2</mn></msup>
</math>
</p>
<!-- Block math: Quadratic formula -->
<math display="block">
<mi>x</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo>−</mo><mi>b</mi>
<mo>±</mo>
<msqrt>
<msup><mi>b</mi><mn>2</mn></msup>
<mo>−</mo>
<mn>4</mn><mi>a</mi><mi>c</mi>
</msqrt>
</mrow>
<mrow>
<mn>2</mn><mi>a</mi>
</mrow>
</mfrac>
</math>
<!-- Fraction notation -->
<math>
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</math>
<!-- Complex expression with matrix -->
<math display="block">
<mrow>
<mo>[</mo>
<mtable>
<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>§Accessibility
MathMLprovides built-in semantic accessibility- Screen readers can navigate and speak mathematical expressions
- Consider providing text alternatives for complex equations
- Ensure proper use of
MathMLsemantic elements - Test with assistive technologies that support
MathML
§WHATWG Specification
Trait Implementations§
Source§impl HtmlElement for Math
impl HtmlElement for Math
impl EmbeddedContent for Math
impl FlowContent for Math
impl PalpableContent for Math
impl PhrasingContent for Math
Auto Trait Implementations§
impl Freeze for Math
impl RefUnwindSafe for Math
impl Send for Math
impl Sync for Math
impl Unpin for Math
impl UnwindSafe for Math
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more