我正在尝试在网页上显示数学公式。 但是当我写下像以下的HTML代码时
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Binomial Theorem</title>
</head>
<body>
<p>Binomial Theorem:</p>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup>
<mfenced>
<mrow>
<mi>a</mi>
<mo>+</mo>
<mi>b</mi>
</mrow>
</mfenced>
<mn>2</mn>
</msup>
<mo>=</mo>
<msup>
<mrow>
<mi>a</mi>
</mrow>
<mn>2</mn>
</msup>
<mo>+</mo>
<msup>
<mrow>
<mi>b</mi>
</mrow>
<mn>2</mn>
</msup>
<mo>+</mo>
<mrow>
<mn>2</mn>
<mi>a</mi>
<mi>b</mi>
</mrow>
</mrow>
</math>
</body>
</html>
结果只是
二项式定理:
a + b 2 = a 2 + b 2 + 2 a b
它不像公式
帮我在HTML中使用MathML 谢谢,
答案 0 :(得分:2)
答案 1 :(得分:2)
我会对您的网页进行3次更改:
<!DOCTYPE html>
将此页面标识为浏览器为HTML5页面。html
元素的名称空间声明。拥有它并不会伤害任何东西,但它没有必要。无论如何,您可能会将其包含在每个math
元素中。</head>
上方的最后一行,则数学将在所有浏览器中显示,而不仅仅是Firefox: <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
答案 2 :(得分:1)
目前仅在Firefox浏览器上支持MathML。试试Firefox浏览器。
答案 3 :(得分:0)
HTML5 MathML提供了一种在网页上编写数学的方法。所有数学表达式都写在标记内。数学元素有很多子元素。不幸的是,并非所有浏览器都支持math元素。因此,请使用最新的mozilla或chrome进行渲染。
<math>
<mtable>
<mtr>
<mtd> <mn>1</mn> </mtd>
<mtd> <mn>0</mn> </mtd>
<mtd> <mn>1</mn> </mtd>
</mtr>
<mtr>
<mtd> <mn>1</mn> </mtd>
<mtd> <mn>1</mn> </mtd>
<mtd> <mn>1</mn> </mtd>
</mtr>
<mtr>
<mtd> <mn>0</mn> </mtd>
<mtd> <mn>0</mn> </mtd>
<mtd> <mn>1</mn> </mtd>
</mtr>
</mtable>
</math>
“数学”属性有许多子元素-
https://www.etutorialspoint.com/index.php/basic-html/html5-mathml