Displays a MathML formula.


Required Scripts

<script async custom-element="amp-mathml" src=""></script>

Supported Layouts


Renders a MathML formula in an iframe.

The example below displays the quadratic formula:

  data-formula="\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]"

The example below displays Cauchy's integral formula:

  data-formula="\[f(a) = \frac{1}{2\pi i} \oint\frac{f(z)}{z-a}dz\]"

The example below displays a double angle formula for cosines:

  data-formula="$$ \cos(θ+φ)=\cos(θ)\cos(φ)−\sin(θ)\sin(φ) $$"

Inline formula

This is an example of a formula of <amp-mathml layout="container" inline data-formula="`x`"></amp-mathml>, <amp-mathml layout="container" inline data-formula="\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)"></amp-mathml> placed inline in the middle of a block of text. <amp-mathml layout="container" inline data-formula="\( \cos(θ+φ) \)"></amp-mathml> This shows how the formula will fit inside a block of text and can be styled with CSS.

Standalone Use outside valid AMP documents

Bento AMP allows you to use AMP components in non-AMP pages without needing to commit to fully valid AMP. You can take these components and place them in implementations with frameworks and CMSs that don't support AMP. Read more in our guide Use AMP components in non-AMP pages. To find the standalone version of amp-mathml, see bento-mathml.


data-formula (required)

Specifies the formula to render.

inline (optional)

If specified, the component renders inline (inline-block in CSS).

title (optional)

Define a title attribute for the component to propagate to the underlying <iframe> element. The default value is "MathML formula".


See amp-mathml rules in the AMP validator specification.

Version Notes

The 1.0 version of amp-mathml will, by default, only render formulas when they are offscreen to avoid layout shifts that would negatively impact the Page Experience (PX). If a formula is onscreen, it will resize to its correct size dynamically when the user has scrolled the formula out of the viewport. When the component returns to the viewport, they formula should be rendered. For best experience, it is recommended to provide the dimensions of the formula using height and width attributes so formulas onscreen are rendered immediately without causing a layout shift.

Требуется дополнительная помощь?

Вы читали этот документ десятки раз, но так и не нашли ответов на все свои вопросы? Возможно, другие люди столкнулись с такой же проблемой — обратитесь к ним на Stack Overflow.

Перейти на Stack Overflow
Нашли ошибку или недостающую функцию?

Проект AMP активно поощряет ваше участие и сотрудничество! Мы надеемся, что вы станете постоянным участником нашего открытого сообщества, но разовые вклады в работу над задачами, которые вам особенно интересны, также приветствуются.

Перейти на GitHub