The <var> tag in HTML is used to define a variable. It is typically used to represent a variable in a mathematical expression or a placeholder that can be updated dynamically with JavaScript
The content inside <var> tag is often styled differently by browsers to indicate that it is a variable, though this can be customized with CSS.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<body>
<h1>Mathematical Expression</h1>
<!--Driver Code Ends-->
<p>
The equation
<var>x</var> + <var>y</var> = <var>z</var>
represents a simple addition.
</p>
<!--Driver Code Starts-->
</body>
</html>
<!--Driver Code Ends-->
Syntax:
<var> Contents... </var>Other elements that are used in contexts in which <var> are commonly used include:
Tags | Description |
|---|---|
It displays computer code in a monospaced font. | |
It represents user input like keyboard keys. | |
It shows example output from programs. | |
Italicizes text for emphasis or stress. |
Example: Implementation of var tag with help of another example.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<!--Driver Code Ends-->
<body>
<h1>Mathematical Equation</h1>
<p>
Let <var>x</var> be a number.
The equation for calculating <var>y</var> is:
</p>
<p>
<var>y</var> = <var>x <sup>2</sup></var>+ 3<var>x</var> + 2
</p>
<p>
This shows how <var>var</var> tag
is used to indicate variables in
equations or code.
</p>
</body>
<!--Driver Code Starts-->
</html>
<!--Driver Code Ends-->