HTML <var> Tag
Description
The <var> tag in HTML is used to represent the name of a variable in a mathematical expression, programming context, or any other formal notation where a variable is referenced. Its primary purpose is semantic, indicating that the enclosed text should be interpreted as a variable rather than ordinary content.
Visually, most browsers render the <var> content in italic typeface by default, distinguishing it from regular text. However, the tag carries meaning, not just styling, which is important for accessibility, search engines, and automated tools that parse the content.
Common use cases include:
Programming examples: Highlighting variables in code snippets or tutorials.
<p>In JavaScript, you can declare a variable using <var>x</var> like this: <code>let <var>x</var> = 5;</code></p>
Mathematical expressions: Denoting variables in formulas.
<p>The area of a rectangle is calculated as <var>A</var> = <var>length</var> × <var>width</var>.</p>
Technical documentation: Making it clear which elements are placeholders, parameters, or identifiers that can change.
The <var> tag is inline by default, so it can seamlessly appear within paragraphs, lists, or other textual content without breaking the flow. It’s often paired with <code> or <kbd> for more complex technical or programming documentation, helping readers differentiate between variables, code, and keyboard inputs.
Properties
- Permitted Parents
- Any element that accepts phrasing content
- Content
- Inline and text
- Start/End Tags
- Start tag: required, End tag: required
Example
Attributes
None
Global Attributes
The <var> tag also supports the Global Attributes in HTML5
Event Attributes
The <var> tag also supports the Event Attributes in HTML5
Browser Support
The following information will show you the current browser support for the HTML <var> tag. Hover over a browser icon to see the version that first introduced support for this HTML tag.
This tag is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 26th December 2025
