Latest web development tutorials
 

HTML DOM title Propery

< Document Object

Example

Get the title of the current document:

var x = document.title;

The result of x will be:

My title
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The title property sets or returns the title of the current document (the text inside the HTML title element).


Browser Support

Property
title Yes Yes Yes Yes Yes

Syntax

Return the title property:

document.title

Set the title property:

document.title=newTitle

Property Values

Value Description
newTitle Specifies a new title text

Technical Details

Return Value: A String, representing the title of the document
DOM Version Core Level 2 Document Object

Examples

More Examples

Example

Change the title of the document:

document.title = "Some new title text";
Try it Yourself »

Related Pages

HTML reference: HTML <title> tag

JavaScript reference: HTML DOM Title Object


< Document Object