HTML5 MathML
HTML5ではドキュメント内でMathML要素を使用できます。対応するタグは <math>...</math> です。
MathMLは数学マークアップ言語であり、XML(標準汎用マークアップ言語のサブセット)に基づく標準で、インターネット上で数学記号や数式を記述するためのマークアップ言語です。
注意:現在、Firefox または Safari ブラウザのみがサポートしており、ほとんどのブラウザはMathMLタグをサポートしていません。お使いのブラウザがこのタグをサポートしていない場合は、最新版の Firefox または Safari ブラウザで表示できます。
また、サードパーティのスタイルライブラリを使用して数学マークアップをサポートできます。この章で使用するスタイルライブラリは、以下のボタンをクリックしてダウンロードできます:
mathml.zip をダウンロード
MathML 例
以下は簡単な MathML の例です:
例
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<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>
</mrow>
</math>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<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>
</mrow>
</math>
</body>
</html>
試してみる »
サードパーティライブラリを使用してサポートする:
例
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
<script type="text/javascript" src="/static.jyshare.com/assets/js/mathml/mspace.js?v=2"></script>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<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>
</mrow>
</math>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
<script type="text/javascript" src="/static.jyshare.com/assets/js/mathml/mspace.js?v=2"></script>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<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>
</mrow>
</math>
</body>
</html>
試してみる »
実行結果の図は次のとおりです:

以下の例ではいくつかの演算子を追加しています:
例
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mrow>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<mrow>
<mn>4</mn>
<mo></mo>
<mi>x</mi>
</mrow>
<mo>+</mo>
<mn>4</mn>
</mrow>
<mo>=</mo>
<mn>0</mn>
</mrow>
</math>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mrow>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<mrow>
<mn>4</mn>
<mo></mo>
<mi>x</mi>
</mrow>
<mo>+</mo>
<mn>4</mn>
</mrow>
<mo>=</mo>
<mn>0</mn>
</mrow>
</math>
</body>
</html>
試してみる »
サードパーティライブラリを使用してサポートする:
例
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
<script type="text/javascript" src="/static.jyshare.com/assets/js/mathml/mspace.js?v=2"></script>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mrow>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<mrow>
<mn>4</mn>
<mi>x</mi>
</mrow>
<mo>+</mo>
<mn>4</mn>
</mrow>
<mo>=</mo>
<mn>0</mn>
</mrow>
</math>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
<script type="text/javascript" src="/static.jyshare.com/assets/js/mathml/mspace.js?v=2"></script>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mrow>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<mrow>
<mn>4</mn>
<mi>x</mi>
</mrow>
<mo>+</mo>
<mn>4</mn>
</mrow>
<mo>=</mo>
<mn>0</mn>
</mrow>
</math>
</body>
</html>
試してみる »
実行結果の図は次のとおりです:

以下の例は2×2行列です。Firefox 3.5以降で確認できます:
例
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mi>A</mi>
<mo>=</mo>
<mfenced open="[" close="]">
<mtable>
<mtr>
<mtd><mi>x</mi></mtd>
<mtd><mi>y</mi></mtd>
</mtr>
<mtr>
<mtd><mi>z</mi></mtd>
<mtd><mi>w</mi></mtd>
</mtr>
</mtable>
</mfenced>
</mrow>
</math>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mi>A</mi>
<mo>=</mo>
<mfenced open="[" close="]">
<mtable>
<mtr>
<mtd><mi>x</mi></mtd>
<mtd><mi>y</mi></mtd>
</mtr>
<mtr>
<mtd><mi>z</mi></mtd>
<mtd><mi>w</mi></mtd>
</mtr>
</mtable>
</mfenced>
</mrow>
</math>
</body>
</html>
試してみる »
サードパーティライブラリを使用してサポートする:
例
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
<script type="text/javascript" src="/static.jyshare.com/assets/js/mathml/mspace.js?v=2"></script>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mi>A</mi>
<mo>=</mo>
<mfenced open="[" close="]">
<mtable>
<mtr>
<mtd><mi>x</mi></mtd>
<mtd><mi>y</mi></mtd>
</mtr>
<mtr>
<mtd><mi>z</mi></mtd>
<mtd><mi>w</mi></mtd>
</mtr>
</mtable>
</mfenced>
</mrow>
</math>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>サンプル(example.com)</title>
<script type="text/javascript" src="/static.jyshare.com/assets/js/mathml/mspace.js?v=2"></script>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mi>A</mi>
<mo>=</mo>
<mfenced open="[" close="]">
<mtable>
<mtr>
<mtd><mi>x</mi></mtd>
<mtd><mi>y</mi></mtd>
</mtr>
<mtr>
<mtd><mi>z</mi></mtd>
<mtd><mi>w</mi></mtd>
</mtr>
</mtable>
</mfenced>
</mrow>
</math>
</body>
</html>
試してみる »
実行結果の図は次のとおりです:
