HTML5 Reference

HTML <samp> tag

Definition

The <samp> tag is used to define sample computer code.

Example


<samp>This text will look like sample computer code.</samp>
This text will look like sample computer code.

Attributes

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


<samp> Specific Attributes
Attribute Value Description Example
There are no required or optional attributes specific to the <samp> tag.
<samp> 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.

<samp class="name">Sample Computer Code</samp> 
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<samp id="name">Sample Computer Code</samp> 
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

<samp style="color:red;">Sample Computer Code</samp> 
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<samp title="Content info">Sample Computer Code</samp> 
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<samp accesskey="a">Sample Computer Code</samp> 
tabindexSpecifies a tab order for the element.

<samp tabindex="1">Sample Computer Code</samp> 
Language
dirSpecifies the directional flow of the content.

<!-- The text will flow from left to right -->
<samp dir="ltr">Sample Computer Code</samp> 
<!-- The text will flow from right to left -->
<samp dir="rtl">Sample Computer Code</samp> 
langSpecifies a language code for the content of the element.

<samp lang="en">Sample Computer Code</samp> 
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. -->
<samp spellcheck="true">Sample Computer Code</samp>  
translateSpecifies an inline style for the element allowing you to apply the style to the content.

<!-- Valid values yes and no. -->
<!-- Default yes. -->
<samp translate="no">Sample Computer Code</samp>  
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<samp contenteditable="true">Sample Computer Code</samp>  
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
<samp draggable="true">Sample Computer Code</samp> 
hiddenSpecifies whether the element is not yet, or no longer, relevant.

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

 <!-- Executes go() function -->
<samp oncopy="go()">Sample Computer Code</samp>  
oncutThe script to be run when the user cuts the content of an element.

 <!-- Executes go() function -->
<samp oncut="go()">Sample Computer Code</samp> 
onpasteThe script to be run when the user pastes some content into an element.

 <!-- Executes go() function -->
<samp onpaste="go()">Sample Computer Code</samp> 
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<samp ondrag="go()">Sample Computer Code</samp> 
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
<samp ondragend="go()">Sample Computer Code</samp> 
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
<samp ondragenter="go()">Sample Computer Code</samp> 
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
<samp ondragleave="go()">Sample Computer Code</samp> 
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
<samp ondragover="go()">Sample Computer Code</samp> 
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<samp ondragstart="go()">Sample Computer Code</samp> 
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<samp ondrop="go()">Sample Computer Code</samp> 
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<samp onblur="go()">Sample Computer Code</samp> 
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<samp onchange="go()">Sample Computer Code</samp> 
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<samp oncontextmenu="go()">Sample Computer Code</samp> 
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<samp onfocus="go()">Sample Computer Code</samp> 
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<samp oninput="go()">Sample Computer Code</samp> 
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<samp oninvalid="go()">Sample Computer Code</samp> 
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<samp onreset="go()">Sample Computer Code</samp> 
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
<samp onselect="go()">Sample Computer Code</samp> 
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
<samp onsubmit="go()">Sample Computer Code</samp> 
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
<samp onkeydown="go()">Sample Computer Code</samp> 
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
<samp onkeypress="go()">Sample Computer Code</samp> 
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
<samp onkeyup="go()">Sample Computer Code</samp> 
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
<samp onabort="go()">Sample Computer Code</samp> 
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

 <!-- Executes go() function -->
<samp oncanplay="go()">Sample Computer Code</samp> 
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 -->
<samp oncanplaythrough="go()">Sample Computer Code</samp> 
oncuechangeThe script to be run when the cue changes when using the track element.

 <!-- Executes go() function -->
<samp oncuechange="go()">Sample Computer Code</samp> 
ondurationchangeThe script to be run when the length of the media is changed.

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

 <!-- Executes go() function -->
<samp onemptied="go()">Sample Computer Code</samp> 
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
<samp onended="go()">Sample Computer Code</samp> 
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
<samp onloadeddata="go()">Sample Computer Code</samp> 
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<samp onloadedmetadata="go()">Sample Computer Code</samp> 
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<samp onloadstart="go()">Sample Computer Code</samp> 
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<samp onpause="go()">Sample Computer Code</samp> 
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<samp onplay="go()">Sample Computer Code</samp> 
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<samp onplaying="go()">Sample Computer Code</samp> 
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<samp onprogress="go()">Sample Computer Code</samp> 
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
<samp onratechange="go()">Sample Computer Code</samp> 
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
<samp onseeked="go()">Sample Computer Code</samp> 
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
<samp onseeking="go()">Sample Computer Code</samp> 
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
<samp onstalled="go()">Sample Computer Code</samp> 
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
<samp onsuspend="go()">Sample Computer Code</samp> 
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
<samp ontimeupdate="go()">Sample Computer Code</samp> 
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
<samp onvolumechange="go()">Sample Computer Code</samp> 
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
<samp onwaiting="go()">Sample Computer Code</samp> 
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
<samp onclick="go()">Sample Computer Code</samp> 
ondblclickThe script to be run when a mouse is double clicked on an element.

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

 <!-- Executes go() function -->
<samp onmousedown="go()">Sample Computer Code</samp> 
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<samp onmousemove="go()">Sample Computer Code</samp> 
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<samp onmouseout="go()">Sample Computer Code</samp> >
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
<samp onmouseover="go()">Sample Computer Code</samp> 
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
<samp onmouseup="go()">Sample Computer Code</samp> 
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
<samp onwheel="go()">Sample Computer Code</samp> 
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
<samp onscroll="go()">Sample Computer Code</samp>  
Window - NONE

Relevant HTML Tutorials

HTML Intermediate - More Text Tags