第38话

数学家

HTML5 MathML
公式恐惧症
🤯
我想在网页上写个勾股定理,难道要用图片截图吗?这也太不高清了!
别怕,用 MathML!这是专门用来描述数学公式的 XML 语言。
勾股定理

看看这优雅的公式:a² + b² = c²

<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>
📝
看起来像天书?
  • mi: 变量 (identifier)
  • mn: 数字 (number)
  • mo: 操作符 (operator)
  • msup: 上标 (superscript)