Open In App

How to define a variable in HTML5 ?

Improve
Improve
Like Article
Like
Save
Share
Report

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.

html




<!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:

  • Google Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 15
  • Safari 4


Last Updated : 18 Jan, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads