HTML <html> tagS2C Home   « HTML <html> tag

HTML <html> tag

The <html> tag denotes the document root element of a HTML document.

Example


<!DOCTYPE html>   <!-- The DOCTYPE declaration always comes first in a HTML document --> 
<html lang="en">
<!-- Everything else goes between the start and end HTML tags. --> 

<head>
<!-- The header contains meta information pertaining to the HTML document as well as a title and other stuff we will discuss in HTML Intermediate/Advanced lessons. External files such as CSS stylesheets and JavaScript files are also imported in the header section of our HTML file. -->
  <title>Appears in browser toolbar, favourites and search engine results.</title>
</head>

<body>
<!-- The content of the web page appears in the body section. -->
</body>

<!-- We complete the HTML file with the closing HTML tag. -->
</html>

Attributes

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


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

<html class="name">HTML document content</html>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<html id="name">HTML document content</html>
styleSpecifies an inline style for the element allowing you to apply the style to the content.

<html style="color:red;">HTML document content</html>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<html title="Content info">HTML document content</html>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<html accesskey="a">HTML document content</html>
tabindexSpecifies a tab order for the element.

<html tabindex="1">HTML document content</html>
Language
dirSpecifies the directional flow of the content.

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

<html lang="en">HTML document content</html>
spellcheckSpecifies an inline style for the element allowing you to apply the style to the content.

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

<!-- Valid values yes and no. -->
<!-- Default yes. -->
<html translate="no">HTML document content</html> 
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<html contenteditable="true">HTML document content</html> 
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
<html draggable="true">HTML document content</html>
hiddenSpecifies whether the element is not yet, or no longer, relevant.

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

 <!-- Executes go() function -->
<html oncopy="go()">HTML document content</html> 
oncutThe script to be run when the user cuts the content of an element.

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

 <!-- Executes go() function -->
<html onpaste="go()">HTML document content</html>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<html ondrag="go()">HTML document content</html>
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
<html ondragend="go()">HTML document content</html>
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
<html ondragenter="go()">HTML document content</html>
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
<html ondragleave="go()">HTML document content</html>
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
<html ondragover="go()">HTML document content</html>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<html ondragstart="go()">HTML document content</html>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<html ondrop="go()">HTML document content</html>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<html onblur="go()">HTML document content</html>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<html onchange="go()">HTML document content</html>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<html oncontextmenu="go()">HTML document content</html>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<html onfocus="go()">HTML document content</html>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<html oninput="go()">HTML document content</html>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<html oninvalid="go()">HTML document content</html>
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<html onreset="go()">HTML document content</html>
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
<html onselect="go()">HTML document content</html>
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
<html onsubmit="go()">HTML document content</html>
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
<html onkeydown="go()">HTML document content</html>
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
<html onkeypress="go()">HTML document content</html>
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
<html onkeyup="go()">HTML document content</html>
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
<html onabort="go()">HTML document content</html>
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

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

 <!-- Executes go() function -->
<html oncuechange="go()">HTML document content</html>
ondurationchangeThe script to be run when the length of the media is changed.

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

 <!-- Executes go() function -->
<html onemptied="go()">HTML document content</html>
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
<html onended="go()">HTML document content</html>
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
<html onloadeddata="go()">HTML document content</html>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<html onloadedmetadata="go()">HTML document content</html>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<html onloadstart="go()">HTML document content</html>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<html onpause="go()">HTML document content</html>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<html onplay="go()">HTML document content</html>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<html onplaying="go()">HTML document content</html>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<html onprogress="go()">HTML document content</html>
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
<html onratechange="go()">HTML document content</html>
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
<html onseeked="go()">HTML document content</html>
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
<html onseeking="go()">HTML document content</html>
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
<html onstalled="go()">HTML document content</html>
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
<html onsuspend="go()">HTML document content</html>
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
<html ontimeupdate="go()">HTML document content</html>
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
<html onvolumechange="go()">HTML document content</html>
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
<html onwaiting="go()">HTML document content</html>
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
<html onclick="go()">HTML document content</html>
ondblclickThe script to be run when a mouse is double clicked on an element.

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

 <!-- Executes go() function -->
<html onmousedown="go()">HTML document content</html>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<html onmousemove="go()">HTML document content</html>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<html onmouseout="go()">HTML document content</html>
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
<html onmouseover="go()">HTML document content</html>
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
<html onmouseup="go()">HTML document content</html>
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
<html onwheel="go()">HTML document content</html>
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
<html onscroll="go()">HTML document content</html> 
Window - NONE

Relevant HTML Tutorials

HTML Basics - HTML Structure - Document