The <var> element marks the name of a variable in a mathematical expression or a programming context — for example x in algebra or userId in documentation.
Most browsers render it in italics. For source code snippets use <code>, for keyboard input <kbd>, and for sample program output <samp>. Do not use <var> only to get italic text.
Baseline · Widely available.
Not deprecated. Stable across browsers since about July 2015 (and much earlier in practice).
Not for decoration.
If you only need italics or emphasis, use <em>, <i>, or a <span> with CSS — keep <var> for real variable names.
Not a programming keyword.
In HTML, <var> is an element name. It is unrelated to the var keyword in JavaScript.
Syntax
HTML Syntax
syntax.html
<var>name</var>
Both start and end tags are required. Content is phrasing content. Place it where phrasing content is allowed (inside a paragraph, sentence, or similar).
Reference
Attributes
<var> has no element-specific attributes — only globals. Compare it with related computer-text elements:
The variables minSpeed and maxSpeed control the minimum and maximum speed in RPM.
How It Works
Identify the variable names you are talking about in prose.
Wrap only those names in <var>.
Keep the explanation as normal text around them.
Readers can tell which words are identifiers, not ordinary words.
Example 3 — Several Variables in One Formula
Repeat <var> for each named quantity, then define them in the same paragraph.
HTML
<p>
The volume of a box is
<var>l</var> × <var>w</var> × <var>h</var>,
where <var>l</var> is length, <var>w</var> is width,
and <var>h</var> is height.
</p>
One line: wrap only the variable name in <var>, keep styling in CSS, and use <code> for full snippets.
UA style
Default CSS Settings
Typical user-agent styling for var (exact values can vary slightly by browser):
default.css
var {
font-style: italic;
}
Override when needed, for example font-style: normal or a monospace stack for identifier-heavy docs.
Frequently Asked Questions
The var element marks the name of a variable in math or programming — for example x in an equation or minSpeed in docs. It is not a CSS or JavaScript keyword.
No. It only supports the global attributes (id, class, lang, title, and so on).
var names a variable. code marks a fragment of computer code (a statement, filename, or snippet). You can nest them when a variable appears inside code text.
Most browsers set font-style: italic by default. You can override that with CSS when italic is not the look you want.
No. That is presentational misuse. Prefer em for stress emphasis, i for an alternate voice or idiom, or a span with CSS for pure styling.
No. It is Baseline and widely available across modern browsers.