var – variable
<var>x</var>
A variable: an unknown in a formula, a variable in a program or a placeholder that the reader replaces with their own value. The browser displays it in italics.
- Default display:
display: inline - End tag: required
- Content: phrasing content
- Where it can be used: anywhere phrasing content is allowed
- DOM interface:
HTMLElement
Attributes
Only global attributes.
Examples
A formula and a placeholder:
<p>The area of a rectangle is <var>a</var> · <var>b</var>.</p> <p>The profile URL is <code>https://www.example.com/user/<var>name</var>/</code>.</p>
Things to watch out for
- Complex formulas are written in MathML (the
mathelement);varis suitable for individual variables in the text. - The name of a variable in a program is more often written as
code;varinsidecodemarks the part the reader replaces.
Browser support
Baseline – widely available: works in all major browsers and has for a long time (since 2015 at the latest). Since version: Chrome 1, Firefox 1, Safari 4. As of October 2026 (MDN browser-compat-data).
Related:
code – code
i – text in an alternate voice
sub – subscript
sup – superscript