Skip to: content, navigation

var (HTML element)

Spec
Depr. Empty Version
No No HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+
Full Full Full Full

Syntax

<var>
</var>

Description

The var element is used to indicate that the text is a variable and shouldn’t be taken literally. Instead, it’s an example that should be replaced with your own value.

The example code would render as shown in Figure 1.

Figure 1. An example usage of var Example of var element

Example

In the following example, a customer is asked to enter two pieces of information, which are marked up as variables:

<p>To get access to the system you first need to enter your
    username, e.g. <var>monkeyboy123</var>, followed by your unique
    6-digit customer ID beginning with C, e.g. <var>C13345</var>.</p>

Use This For …

This element is used to indicate that the phrase is a variable of some kind—most likely in the context of showing an example value, as illustrated in the example HTML above.

Compatibility

Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.0 1.5 2.0 1.3 2.0 3.0 9.2 9.5
Full Full Full Full Full Full Full Full Full Full Full

The var has good browser support; most of the major browsers render the variable in italics (similar to other reference-type phrase elements, such as cite and dfn).

User-contributed notes

ID:
#1
Contributed:
by AutisticCuckoo
Date:
Fri, 28 Mar 2008 10:54:37 GMT

That example is not very good. You'd normally use VAR to mark up a *placeholder*, not a sample value.

A more realistic example would be something like this (perhaps from an instruction manual for a corporate telephone system):

<p>To forward incoming calls to another extension, press <kbd>* 21 * <var>extension</var> #</kbd>.</p>

The VAR markup indicates that you're not supposed to punch in the letters e-x-t-e-n-s-i-o-n, but replace that placeholder with the actual extension number.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

Search