<var>

Term side of the Card.
Topic: Semantics
Unit title: <var>
Categories: Tag
Explanation side of the Card

Explanation: The element that represents a variable in mathematical expressions or programming contexts. It's typically displayed in italics, which distinguishes it from regular text.

Browser compatibility:
  • The chrome browser supports this feature starting from version 1.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 1.
  • The safari browser supports this feature starting from version 4.
Availability: 

Example

Wronghtml
<p>
  The area is <i>w</i> times <i>h</i>.
</p>
Righthtml
<p>
  The area is <var>w</var> times <var>h</var>.
</p>

<var> marks the letters as variables, not just italic text.

Common mistakes

  • Using <var> for any italic text.
  • Using <var> for whole code snippets instead of <code>.

Interview questions

What is the difference between <var> and <code>?

<var> marks a variable name in prose or math, while <code> marks a fragment of computer code.

Should I use <var> or MathML?

Use <var> for variables in text and <math> for full equations.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy