HTML <var> Element
The <var> element represents a variable in a mathematical expression, programming context, formula, or other technical content. Browsers typically display its text in an italic typeface by default.
Syntax
<var>variable</var>
Attributes
The <var> element supports the global HTML attributes. It does not have any element-specific attributes.
Example
This example uses the <var> element to identify the variables in a simple formula for calculating the area of a rectangle.
Usage Notes
Use the <var> element when text represents a variable, placeholder, or symbolic value in mathematical, scientific, or programming-related content.
The <var> element provides semantic meaning rather than simply making text italic. If text should be italicized only for visual presentation, use CSS instead.
The <var> element can be combined with elements such as <code>, <samp>, and <kbd> when documenting programming, computer input, or technical examples.
Accessibility
Use <var> consistently when identifying variables so their purpose is clear within the surrounding content. Do not rely on italic styling alone to explain what a variable represents; provide enough accompanying text for users to understand its meaning.
Browser Support
Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.
For detailed browser compatibility information, see Can I Use: HTML <var> Element .
Related Elements
The <var> element is related to other elements used for technical content, including <code> for computer code, <samp> for sample computer output, and <kbd> for user input.
Specifications
The <var> element is defined in the WHATWG HTML Living Standard .
