Description

The HTML element <var> is used to define a variable in a programming logic or a mathematical expression.

The content within this element is displayed in italics.

The below table summarizes its usage.

Usage Details
Placement It is displayed as an Inline element.
Contents It can contain Inline elements and text.
Tags Both the opening and closing tags are required.
Versions HTML 2, 3.2, 4, 4.01, 5

Syntax

Here is the basic syntax of the <var> element.

<var>...</var>

Examples

Run this on IDE

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example - HTML Element var</title>
</head>
<body>
    <p>A sample mathematical expression: <var>y</var> = <var>x</var> + 2</p>
</body>
</html>

Attributes

The following table shows the list of supported and unsupported attributes for the <var> element.

Attribute Type Details
Element-Specific Attributes The tag <var> doesn't have any element-specific attributes.
Global Attributes Like all other HTML tags, the tag <var> supports the HTML Global Attributes.
Event Attributes The tag <var> also supports the HTML Event Attributes.

Browser Compatibility

The tag <var> is supported in all modern browsers.

  • Google Chrome 1+
  • Internet Explorer or Edge 2+
  • Firefox 1+
  • Apple Safari 1+
  • Opera 4+

Related Links