<var> 标签表示变量的名称,或者由用户提供的值。
| 允许内容 | Phrasing content |
| 标签闭合 | Both start and end tags are required |
| 允许的父级元素 | Any element that accepts phrasing content. |
| 规范元素 | HTML, "The var element" |
本元素仅支持 全局属性.
本元素支持 HTMLElement 接口
提示:Gecko 1.9.2 开始,Firefox 支持本元素使用 HTMLSpanElement 接口。
var {
font-style: italic;
}
<p> A simple equation: <var>x</var> = <var>y</var> + 2 </p>
A simple equation: x = y + 2
The output:
{{EmbedLiveSample("Basic_example", 650,80)}}
Using CSS, you can override the default style for the <var> element. In this example, variable names are rendered using bold Courier if it's available, otherwise it falls back to the default monospace font.
var {
font: bold 15px "Courier", "Courier New", monospace;
}
<p>The variables <var>minSpeed</var> and <var>maxSpeed</var> control the minimum and maximum speed of the apparatus in revolutions per minute (RPM).</p>
This HTML uses <var> to enclose the names of two variables.
{{EmbedLiveSample("Overriding_the_default_style", 650, 120)}}