CSS Portal

HTML <var> Tag

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

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

You need to add the <var>width</var> and <var>height</var> to the program.

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
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 26th December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!