Inline
HTML 2.0
The variable element represents a variable in a mathematical expression, programming context, or any placeholder value. It’s typically rendered in italic.
Interactive code playground requires JavaScript. Here's the code:
<p>The formula is <var>E</var> = <var>mc</var><sup>2</sup></p>
<p>Let <var>x</var> = 10 and <var>y</var> = 20</p>
The <var> element marks text that represents a variable or placeholder.
Interactive code playground requires JavaScript. Here's the code:
<p>If <var>a</var> = 5 and <var>b</var> = 3, then <var>a</var> + <var>b</var> = 8</p>
<p>Pythagorean theorem: <var>a</var><sup>2</sup> + <var>b</var><sup>2</sup> = <var>c</var><sup>2</sup></p>
Interactive code playground requires JavaScript. Here's the code:
<p>Assign <var>userName</var> to store the user's name</p>
<p>The value of <var>counter</var> increments by 1</p>
Interactive code playground requires JavaScript. Here's the code:
<p>The function takes two parameters: <var>width</var> and <var>height</var></p>
<p>Returns <var>result</var> as a boolean value</p>
Interactive code playground requires JavaScript. Here's the code:
<p>Replace <var>YOUR_API_KEY</var> with your actual API key</p>
<p>Set <var>DATABASE_URL</var> to your database connection string</p>
Interactive code playground requires JavaScript. Here's the code:
<p>Quadratic formula: <var>x</var> = (-<var>b</var> ± √(<var>b</var><sup>2</sup> - 4<var>ac</var>)) / 2<var>a</var></p>
<p>Area of circle: <var>A</var> = π<var>r</var><sup>2</sup></p>
Interactive code playground requires JavaScript. Here's the code:
<p>Where <var>π</var> ≈ 3.14159</p>
<p>Speed of light <var>c</var> = 299,792,458 m/s</p>
<!-- Variables in math/programming -->
< p > Let < var > x </ var > = 5 </ p >
< p > Use < code > console.log() </ code ></ p >
< p > Press < kbd > Enter </ kbd ></ p >
< p > Output: < samp > Success </ samp ></ p >
Interactive code playground requires JavaScript. Here's the code:
<article>
<h3>GET /users/<var>id</var></h3>
<p>Retrieves a user by their unique <var>id</var>.</p>
<h4>Parameters</h4>
<ul>
<li><var>id</var> (integer): The user's unique identifier</li>
</ul>
<h4>Response</h4>
<p>Returns a user object with <var>name</var>, <var>email</var>, and <var>createdAt</var>.</p>
</article>
Interactive code playground requires JavaScript. Here's the code:
<div class="tutorial">
<h4>Solving for <var>x</var></h4>
<ol>
<li>Given: 2<var>x</var> + 5 = 15</li>
<li>Subtract 5: 2<var>x</var> = 10</li>
<li>Divide by 2: <var>x</var> = 5</li>
</ol>
<p>Therefore, <var>x</var> = 5</p>
</div>
Interactive code playground requires JavaScript. Here's the code:
<section>
<h4>Environment Variables</h4>
<dl>
<dt><var>PORT</var></dt>
<dd>The port number for the server (default: 3000)</dd>
<dt><var>DATABASE_URL</var></dt>
<dd>Connection string for the database</dd>
<dt><var>API_KEY</var></dt>
<dd>Your API authentication key</dd>
</dl>
</section>
Interactive code playground requires JavaScript. Here's the code:
<div class="cli-docs">
<p>Usage: <code>npm install <var>package-name</var></code></p>
<p>Example: <code>git clone <var>repository-url</var></code></p>
<p>Format: <code>docker run -p <var>host-port</var>:<var>container-port</var> <var>image</var></code></p>
</div>
Customize variable appearance:
Interactive code playground requires JavaScript. Here's the code:
<style>
var {
font-style: italic;
color: #6f42c1;
font-weight: 600;
}
</style>
<p>The equation <var>E</var> = <var>mc</var><sup>2</sup> is Einstein's famous formula.</p>
Interactive code playground requires JavaScript. Here's the code:
<style>
var {
font-family: 'Courier New', monospace;
font-style: normal;
background: #f0f0f0;
padding: 2px 6px;
border-radius: 3px;
color: #d73a49;
}
</style>
<p>Set <var>username</var> and <var>password</var> in the config file.</p>
Interactive code playground requires JavaScript. Here's the code:
<p>JavaScript example:</p>
<pre><code>function calculate(<var>x</var>, <var>y</var>) {
return <var>x</var> + <var>y</var>;
}
let <var>result</var> = calculate(5, 10);</code></pre>
Interactive code playground requires JavaScript. Here's the code:
<div class="math">
<p>Linear equation: <var>y</var> = <var>mx</var> + <var>b</var></p>
<p>Distance formula: <var>d</var> = √((<var>x</var><sub>2</sub> - <var>x</var><sub>1</sub>)<sup>2</sup> + (<var>y</var><sub>2</sub> - <var>y</var><sub>1</sub>)<sup>2</sup>)</p>
<p>Slope: <var>m</var> = (<var>y</var><sub>2</sub> - <var>y</var><sub>1</sub>) / (<var>x</var><sub>2</sub> - <var>x</var><sub>1</sub>)</p>
</div>
Interactive code playground requires JavaScript. Here's the code:
<article>
<h4>Physics Equations</h4>
<ul>
<li>Force: <var>F</var> = <var>ma</var></li>
<li>Kinetic Energy: <var>KE</var> = ½<var>m</var><var>v</var><sup>2</sup></li>
<li>Momentum: <var>p</var> = <var>m</var><var>v</var></li>
<li>Work: <var>W</var> = <var>F</var><var>d</var></li>
</ul>
</article>
< p > This is < var > very </ var > important. </ p >
< p > This is < em > very </ em > important. </ p >
< p > Use the < var > console.log() </ var > function. </ p >
< p > Use the < code > console.log() </ code > function. </ p >
Screen readers typically read <var> content as regular text. The italic styling is visual only.
Make sure variable purpose is clear:
< p > Set < var > x </ var > to the value. </ p >
< p > Set the variable < var > maxConnections </ var > to the maximum number of allowed connections. </ p >
For complex math, provide alternative descriptions:
< span aria-label = " E equals M C squared " >
< var > E </ var > = < var > m </ var >< var > c </ var >< sup > 2 </ sup >
Interactive code playground requires JavaScript. Here's the code:
<p>Sequence: <var>a</var><sub>1</sub>, <var>a</var><sub>2</sub>, <var>a</var><sub>3</sub>, ..., <var>a</var><sub>n</sub></p>
<p>Power: <var>x</var><sup>n</sup></p>
<p>Matrix: <var>M</var><sub><var>i</var>,<var>j</var></sub></p>
Interactive code playground requires JavaScript. Here's the code:
<section>
<h4>Function Signature</h4>
<p>
<code>fetchUser(<var>userId</var>: string, <var>options</var>?: object): Promise<User></code>
</p>
<h4>Description</h4>
<p>
Fetches a user by <var>userId</var>.
Optional <var>options</var> parameter can include cache settings.
</p>
</section>
Browser Version Notes Chrome 1+ Full support Firefox 1+ Full support Safari 1+ Full support Edge 12+ Full support IE 3+ Full support
The <var> element has been supported since the earliest browsers.