HTML <var> tagS2C Home   « HTML <var> tag

Definition

The <var> tag is used to define a variable in some text.

Situations for using the <var> tag could be, as the name implies, an actual variable used in a mathematical expression or programming context, an identifier representing a constant, a symbol identifying a physical quantity, a function parameter or as a placeholder for a term used in prose.

Example


<p>And if one green bottle should accidentally fall...</p>
<p>They'll be <var>x</var> green bottles hanging on the wall</p>

And if one green bottle should accidentally fall...

They'll be x green bottles hanging on the wall

Attributes

The following attributes can be used with the <var> tag.


<var> Specific Attributes
Attribute Value Description Example
There are no required or optional attributes specific to the <var> tag.
<var> Global Attributes
Attribute Description Example
Common
classSpecifies a classname for the element allowing you to apply the style of the predefined class to the content.

<video class="name">Variable Name</var>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<video id="name">Variable Name</var>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

<video style="color:red;">Variable Name</var>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<video title="Content info">Variable Name</var>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<video accesskey="a">Variable Name</var>
tabindexSpecifies a tab order for the element.

<video tabindex="1">Variable Name</var>
Language
dirSpecifies the directional flow of the content.

<!-- The text will flow from left to right -->
<video dir="ltr">Variable Name</var>
<!-- The text will flow from right to left -->
<video dir="rtl">Variable Name</var>
langSpecifies a language code for the content of the element.

<video lang="en">Variable Name</var>
spellcheckSpecifies an inline style for the element allowing you to apply the style to the contentt.

<!-- Valid values true and false. -->
<!-- Default inherited / browser specific. -->
<video spellcheck="true">Variable Name</var> 
translateSpecifies an inline style for the element allowing you to apply the style to the content.

<!-- Valid values yes and no. -->
<!-- Default yes. -->
<video translate="no">Variable Name</var> 
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<video contenteditable="true">Variable Name</var> 
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
<video draggable="true">Variable Name</var>
hiddenSpecifies whether the element is not yet, or no longer, relevant.

<!-- Valid values an empty string or hidden -->
<video hidden>Variable Name</var> 
<video hidden="hidden">Variable Name</var> 
<var> Event Attributes
Attribute Description Example
Document Element
oncopyThe script to be run when the user copies the content of an element.

 <!-- Executes go() function -->
<video oncopy="go()">Variable Name</var> 
oncutThe script to be run when the user cuts the content of an element.

 <!-- Executes go() function -->
<video oncut="go()">Variable Name</var>
onpasteThe script to be run when the user pastes some content into an element.

 <!-- Executes go() function -->
<video onpaste="go()">Variable Name</var>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<video ondrag="go()">Variable Name</var>
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
<video ondragend="go()">Variable Name</var>
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
<video ondragenter="go()">Variable Name</var>
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
<video ondragleave="go()">Variable Name</var>
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
<video ondragover="go()">Variable Name</var>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<video ondragstart="go()">Variable Name</var>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<video ondrop="go()">Variable Name</var>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<video onblur="go()">Variable Name</var>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<video onchange="go()">Variable Name</var>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<video oncontextmenu="go()">Variable Name</var>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<video onfocus="go()">Variable Name</var>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<video oninput="go()">Variable Name</var>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<video oninvalid="go()">Variable Name</var>
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<video onreset="go()">Variable Name</var>
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
<video onselect="go()">Variable Name</var>
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
<video onsubmit="go()">Variable Name</var>
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
<video onkeydown="go()">Variable Name</var>
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
<video onkeypress="go()">Variable Name</var>
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
<video onkeyup="go()">Variable Name</var>
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
<video onabort="go()">Variable Name</var>
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

 <!-- Executes go() function -->
<video oncanplay="go()">Variable Name</var>
oncanplaythroughThe script to be run when a file can be played all the way to the end without further need of buffering.

 <!-- Executes go() function -->
<video oncanplaythrough="go()">Variable Name</var>
oncuechangeThe script to be run when the cue changes when using the track element.

 <!-- Executes go() function -->
<video oncuechange="go()">Variable Name</var>
ondurationchangeThe script to be run when the length of the media is changed.

 <!-- Executes go() function -->
<video ondurationchange="go()">Variable Name</var>
onemptiedThe script to be run when a media resource element suddenly becomes empty, usually due to an error.

 <!-- Executes go() function -->
<video onemptied="go()">Variable Name</var>
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
<video onended="go()">Variable Name</var>
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
<video onloadeddata="go()">Variable Name</var>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<video onloadedmetadata="go()">Variable Name</var>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<video onloadstart="go()">Variable Name</var>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<video onpause="go()">Variable Name</var>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<video onplay="go()">Variable Name</var>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<video onplaying="go()">Variable Name</var>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<video onprogress="go()">Variable Name</var>
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
<video onratechange="go()">Variable Name</var>
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
<video onseeked="go()">Variable Name</var>
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
<video onseeking="go()">Variable Name</var>
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
<video onstalled="go()">Variable Name</var>
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
<video onsuspend="go()">Variable Name</var>
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
<video ontimeupdate="go()">Variable Name</var>
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
<video onvolumechange="go()">Variable Name</var>
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
<video onwaiting="go()">Variable Name</var>
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
<video onclick="go()">Variable Name</var>
ondblclickThe script to be run when a mouse is double clicked on an element.

 <!-- Executes go() function -->
<video ondblclick="go()">Variable Name</var>
onmousedownThe script to be run when he mouse button is pressed down while the cursor is over an element.

 <!-- Executes go() function -->
<video onmousedown="go()">Variable Name</var>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<video onmousemove="go()">Variable Name</var>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<video onmouseout="go()">Variable Name</var>>
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
<video onmouseover="go()">Variable Name</var>
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
<video onmouseup="go()">Variable Name</var>
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
<video onwheel="go()">Variable Name</var>
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
<video onscroll="go()">Variable Name</var> 
Window - NONE

Relevant HTML Tutorials

HTML Intermediate - More Formatting