HTML <title> tagS2C Home   « HTML <title> tag

Definition

The <title> tag defines the document title element of a HTML file and is used as the title in the browser toolbar, favourites and search engine results.

The <title> tag is the only required tag of the <head> </head> element.

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 <title> tag.


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

<title class="name">Title Text</title>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<title id="name">Title Text</title>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

<title style="color:red;">Title Text</title>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<title title="Content info">Title Text</title>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<title accesskey="a">Title Text</title>
tabindexSpecifies a tab order for the element.

<title tabindex="1">Title Text</title>
Language
dirSpecifies the directional flow of the content.

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

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

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

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<title contenteditable="true">Title Text</title> 
draggableSpecifies whether the element is draggable.

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

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

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

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

 <!-- Executes go() function -->
<title onpaste="go()">Title Text</title>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<title ondrag="go()">Title Text</title>
ondragendThe script to be run when an element has stopped being dragged.

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

 <!-- Executes go() function -->
<title ondragenter="go()">Title Text</title>
ondragleaveThe script to be run when an element leaves a valid drop target.

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

 <!-- Executes go() function -->
<title ondragover="go()">Title Text</title>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<title ondragstart="go()">Title Text</title>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<title ondrop="go()">Title Text</title>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<title onblur="go()">Title Text</title>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<title onchange="go()">Title Text</title>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<title oncontextmenu="go()">Title Text</title>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<title onfocus="go()">Title Text</title>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<title oninput="go()">Title Text</title>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<title oninvalid="go()">Title Text</title>
onresetThe script to be run when a dragged element is being dropped.

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

 <!-- Executes go() function -->
<title onselect="go()">Title Text</title>
onsubmitThe script to be run when a form is submitted.

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

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

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

 <!-- Executes go() function -->
<title onkeyup="go()">Title Text</title>
Media
onabortThe script code to be run on abort.

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

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

 <!-- Executes go() function -->
<title oncuechange="go()">Title Text</title>
ondurationchangeThe script to be run when the length of the media is changed.

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

 <!-- Executes go() function -->
<title onemptied="go()">Title Text</title>
onendedThe script to be run when the media has reach the end.

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

 <!-- Executes go() function -->
<title onloadeddata="go()">Title Text</title>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<title onloadedmetadata="go()">Title Text</title>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<title onloadstart="go()">Title Text</title>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<title onpause="go()">Title Text</title>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<title onplay="go()">Title Text</title>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<title onplaying="go()">Title Text</title>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<title onprogress="go()">Title Text</title>
onratechangeThe script to be run when the playback rate changes.

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

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

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

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

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

 <!-- Executes go() function -->
<title ontimeupdate="go()">Title Text</title>
onvolumechangeThe script to be run when the volume has changed or been muted.

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

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

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

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

 <!-- Executes go() function -->
<title onmousedown="go()">Title Text</title>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<title onmousemove="go()">Title Text</title>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<title onmouseout="go()">Title Text</title>
onmouseoverThe script to be run when the mouse cursor moves over an element.

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

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

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

 <!-- Executes go() function -->
<title onscroll="go()">Title Text</title> 
Window - NONE

Relevant HTML Tutorials

HTML Advanced - Metadata