var element

If you don't know what an element is or how you must use it, I recommend you read the "HTML tags and attributes" tutorial that you can find in the HTML tutorials section.

Description

The var element represents a variable, being either a variable in a mathematical formula or computer code, a constant, a parameter in a function, etc.

For marking up variables inside a mathematical formula, the elements of MathML consitute a better alternative to var.

Examples

In our first example, we're making reference to a variable created in a program, along with a couple of parameters passed to the same function.

<p>The function generates a variable named <var>temp</var> and uses it to exchange the values in the parameters <var>param1</var> and <var>param2</var>.</p>

The function generates a variable named temp and uses it to exchange the values in the parameters param1 and param2.

Our second example shows a reference to a variable declared in a formula elsewhere in the document. This document's fragment is explaining its purpose in that formula.

<p>...where <var>a</var> represents the length of the hypotenuse, and <var>b</var> and <var>c</var> represent the lengths of the other two sides.</p>

...where a represents the length of the hypotenuse, and b and c represent the lengths of the other two sides.

Lastly, a sentence written in colloquial language makes reference to an undetermined number, calling it "n".

<p>If he has <var>n</var> soldiers, you should count at least with <var>n</var>+2 of your own.</p>

If he has n soldiers, you should count at least with n+2 of your own.

Attributes

Global attributes

For information about global attributes refer to this list of global attributes in HTML5.

Events

Global events

For information about global events refer to this list of global events in HTML5.

X

Are you looking for a place to host your next website? I can help you with that!