<mtable>

Baseline 2023 *
Newly available

Since January 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

* Some parts of this feature may have varying levels of support.

<mtable> MathML 元素允许你创建表格或矩阵。其子元素是 <mtr> 元素(表示行),每个子元素都有 <mtd> 元素作为其子元素(表示单元格)。这些元素类似于 HTML 中的 <table><tr><td>元素。

属性

该元素的属性包括全局 MathML 属性。某些浏览器还可能支持以下属性:

align 非标准

指定表格相对于其环境的垂直对齐方式。 可能的值包括:

  • axis(默认):表格的垂直中心与环境的轴线(通常是负号)对齐。
  • baseline:表格的垂直中心与环境的基线对齐。
  • bottom:表格的底部与环境的基线对齐。
  • center:参见基线。
  • top:表格的顶部与环境的基线对齐。

此外,align 属性的值可以行号结尾(例如 align="center 3")。这样可以对齐指定的行而不是整个表格。负整数值从表格底部开始计算行数。

columnalign 非标准

指定单元格的水平对齐方式。允许多个值以空格分隔,并应用于相应的列(例如 columnalign="left right center")。可能的值包括:leftcenter(默认)和 right

columnlines 非标准

指定列边框。允许多个值以空格分隔,并应用于相应的列(例如 columnlines="none none solid")。可能的值包括:none(默认)、soliddashed

columnspacing 非标准

指定表格列之间的间距。允许多个值以空格分隔,并应用于相应的列(例如 columnspacing="1em 2em")。可能的值是 <length-percentage>

frame 非标准

指定整个表格的边框。可能的值包括:none(默认)、soliddashed

framespacing 非标准

指定表格和框架之间添加的额外空间。第一个值指定右侧和左侧的间距;第二个值指定上方和下方的间距。可能的值是 <length-percentage>

rowalign 非标准

指定单元格的垂直对齐方式。允许多个值以空格分隔,并应用于相应的行(例如 rowalign="top bottom axis")。可能的值包括:axisbaseline(默认)、bottomcentertop

rowlines 非标准

指定行边框。允许多个值以空格分隔,并应用于相应的行(例如 rowlines="none none solid")。可能的值包括:none(默认)、soliddashed

rowspacing 非标准

指定表格行之间的间距。允许多个值以空格分隔,并应用于相应的行(例如 rowspacing="1em 2em")。可能的值是 <length-percentage>

width 非标准

一个用于指定整个表格的宽度的 <length-percentage>

备注: 对于 width 属性,某些浏览器还可能接受旧版 MathML 长度

示例

与行号对齐

html
<math display="block">
  <mi>X</mi>
  <mo>=</mo>
  <mtable frame="solid" rowlines="solid" align="axis 3">
    <mtr>
      <mtd><mi>A</mi></mtd>
      <mtd><mi>B</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mi>C</mi></mtd>
      <mtd><mi>D</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mi>E</mi></mtd>
      <mtd><mi>F</mi></mtd>
    </mtr>
  </mtable>
</math>

规范

Specification
MathML Core
# table-or-matrix-mtable

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
mtable
align
Non-standard
columnalign
Non-standard
columnlines
Non-standard
columnspacing
Non-standard
frame
Non-standard
framespacing
Non-standard
rowalign
Non-standard
rowlines
Non-standard
rowspacing
Non-standard
width
Non-standard
Named spaces (e.g. thinmathspace to mean 3/18em)
DeprecatedNon-standard

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.

参见