Français

<var>

Representing a variable in a formula or code

  • HTML
  • accessibility
  • semantics

<var> — The variable

The <var> element represents a variable: in a mathematical formula, in pseudo-code, or in a technical explanation. The browser renders it in italics by default.

When to use it

You want to designate a variable in an equation, a function parameter in an explanation, or a placeholder in a command. For example: replace filename with your file name.

What you gain

Accessibility: screen readers do not treat <var> differently. The italic rendering helps visually, and the markup gives meaning in the code.

Code example

<p>The area of a circle is <var>A</var> = π<var>r</var><sup>2</sup>.</p>
 
<p>Run <code>cp <var>source</var> <var>destination</var></code> to copy the file.</p>

Further reading