HTML <var> tag is a phrase element that serves to specify a placeholder for a mathematical expression or within a programming scenario.
The text enclosed within the <var> tag displays in an italic style on the majority of web browsers, although it can be superseded by applying suitable CSS properties.
Following are some related elements of <var> tag, which can also be used for the same context:
- <code>: To determine the computer programming code.
- <kbd>: To determine the keyboard input.
- <samp>: To determine the sample output.
Syntax
Example
<var>........</var>
Here are some details regarding the HTML <var> element:
| Display | Inline |
|---|---|
| Start tag/End tag | Start and End tag |
| Usage | Formatting |
Example
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML var tag</title>
</head>
<body>
<h2>Example of var tag</h2>
<p>Following is equation for distributive law</p>
<p><var>a</var>(<var>b</var>+<var>c</var>)=<var>ab</var>+<var>ac</var></p>
</body>
</html>
Output:
Attribute:
Tag-specific attributes:
The <var> element in HTML does not include any particular attribute.
Global attribute:
The <var> tag facilitates the implementation of Global attributes within HTML.
Event attribute:
The <var> tag facilitates the Event attributes in HTML.
Supporting Browsers
| Element | Chrome | IE | Firefox | Opera | Safari |
|---|---|---|---|---|---|
<var> |
Yes | Yes | Yes | Yes | Yes |