Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html
var

How to use the var element in HTML

Ayesha Naeem

The <var> element in HTML defines a text as a variable and can be used to define variables of a mathematical expression or variables of a piece of code. The text enclosed in the <var> element is normally displayed in italics.

Note: The <var> element supports all global attributes and event attributes.

Syntax

Example

The following example demonstrates how to use the <var> element in HTML.

The example above shows the code to add two numbers written in HTML. Each of the variables appears italicized because they are enclosed in a <var> tag. The <br> tag is added for formatting.

RELATED TAGS

html
var

CONTRIBUTOR

Ayesha Naeem
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring