Open In App

How to define a variable in HTML5 ?

The <var> tag is used to define variables in HTML and specify mathematical equations or computer programs. The content inside the tag is usually displayed in italics in most browsers.

Note: This tag is not deprecated but using CSS can create more dynamic effects. The <var> tag also supports the Global Attributes and Event Attributes in HTML.



Syntax:

<var> Contents... </var>

Example: In this example, we will see how to create a variable in HTML5.




<!DOCTYPE html>
<html>
 
<head>
    <title>
        How to define a
        variable in HTML5?
    </title>
 
    <style>
        body {
            text-align: center;
        }
 
        .gfg {
            font-size: 40px;
            font-weight: bold;
            color: green;
        }
 
        .geeks {
            font-size: 25px;
            font-weight: bold;
        }
    </style>
</head>
 
<body>
    <div class="gfg">GeeksForGeeks</div>
    <h2>
        <var>
            HTML5: How to define a variable?
        </var>
    </h2>
    <var>GeeksforGeeks Variable</var>
</body>
 
</html>

Output:



Supported Browsers are listed below:


Article Tags :