HTML5 <var> Tag

The HTML <var> element is used to represent a variable in a mathematical expression or a programming context.

The only content permitted inside this element is phrasing content. Both start and end tags are required for this element. The parent of the <var> tag can be any element that accepts phrasing content.

The following style is applied to this element by default:

var {
  font-style: italic;
}

Here is an example of using this tag:

<p>If there are <var>n</var> pipes leading to the ice
   cream factory then I expect at <em>least</em> 
   <var>n</var>flavors of ice cream to be available for purchase!</p>

<p>Then he turned to the blackboard and picked up the chalk. 
  After a few moment's thought, he wrote 
  <var>E</var> = <var>m</var> <var>c</var><sup>2</sup>.  
  The teacher looked pleased.</p>

Attributes

This element only accepts global attributes.

Examples

See the Pen HTML var Tag by Tutorialio (@tutorialio) on CodePen.

Further Reading

  1. Read more about the HTML <var> element on MDN.
  2. You can also read the HTML <var> tag reference on W3C.

Reader Comments

1. You can register or login to post a comment. Asking readers to register improves the quality of discussion.

2. As a registered user, you will also get to access features like choosing between a light and dark theme or anything else that we might implement in future.

Follow Us For Updates

FacebookTwitterGoogle+
Go To Top