HTML5 <var> Tag – Usage, Attributes and Examples

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.

Rate this post —

Author: wD94ZrHL

Leave a Reply

Your email address will not be published. Required fields are marked *

0%