<mi>

Baseline 已广泛支持

此功能已成熟,并且在众多设备和浏览器版本上都能正常工作。自 2023 年 1 月以来,它已在各浏览器中可用。

<mi> MathML 元素指示内容应渲染为标识符,例如函数名、变量或符号常量。

默认情况下,包含多个字符的 <mi> 元素渲染为普通文本,而单个字符则渲染为斜体:与 CSS text-transform 属性值为 math-auto 时的格式化行为相同。带有 normal 值的 mathvariant 属性可用于将单个字符重置为普通字体。

为了使用特定形式的字符,例如粗体/斜体、衬线体、无衬线体、手写体/草书体、等宽体、双线体等等,你应该使用相应的数学字母数字符号

注意:在之前的规范 (MathML3) 中,mathvariant 属性用于定义逻辑类别,这些类别可以应用数学字母数字符号的字符格式。相关的值现在已被弃用,预计在未来的浏览器版本中移除。

属性

mathvariant

当前规范中唯一允许的值是 normal(不区分大小写)

normal

使用默认/普通渲染,移除单个字符自动设置为斜体的样式。

已弃用的旧值有

bold 已弃用

尝试使用粗体字符,例如 "𝐀"。

italic 已弃用

尝试使用斜体字符,例如 "𝐴"。

bold-italic 已弃用

尝试使用粗斜体字符,例如 "𝑨"。

double-struck 已弃用

尝试使用双线字符,例如 "𝔸"。

bold-fraktur 已弃用

尝试使用粗体德文黑体字符,例如 "𝕬"。

script 已弃用

尝试使用手写体字符,例如 "𝒜"。

bold-script 已弃用

尝试使用粗体手写体字符,例如 "𝓐"。

fraktur 已弃用

尝试使用德文黑体字符,例如 "𝔄"。

sans-serif 已弃用

尝试使用无衬线字符,例如 "𝖠"。

bold-sans-serif 已弃用

尝试使用粗体无衬线字符,例如 "𝗔"。

sans-serif-italic 已弃用

尝试使用无衬线斜体字符,例如 "𝘈"。

sans-serif-bold-italic 已弃用

尝试使用粗体无衬线斜体字符,例如 "𝘼"。

monospace 已弃用

尝试使用等宽字符,例如 "𝙰"。

initial 已弃用

尝试使用 initial 字符,例如 "𞸢"。

tailed 已弃用

尝试使用 tailed 字符,例如 "𞹂"。

looped 已弃用

尝试使用 looped 字符,例如 "𞺂"。

stretched 已弃用

尝试使用 stretched 字符,例如 "𞹢"。

此元素还接受全局 MathML 属性

示例

html
<math display="block">
  <!-- Multiple characters render as "normal" text -->
  <mi>sin</mi>
</math>
<hr />
<math display="block">
  <!-- Single characters render as italic by default (i.e. "A" renders as "𝐴") -->
  <mi>A</mi>
</math>
<hr />
<math display="block">
  <!-- Use mathvariant="normal" to make single character render as normal text -->
  <mi mathvariant="normal">F</mi>
</math>
<hr />
<math display="block">
  <!-- To use a specific variant, such as "B" in Fraktur -->
  <mi>𝔅</mi>
</math>

技术摘要

隐式 ARIA 角色 None

规范

规范
MathML Core
# dfn-mi

浏览器兼容性