JavaScript document.title Property

You are Here:

JavaScript document.title Property

The document.title property gets or sets the current title of the document.

Note: This property applies to HTML, SVG, XUL, and other documents in Gecko.

Get Title


HTML Online Editor
<!DOCTYPE html> <html> <head> <title>Example Page</title> </head> <body> <p>Click on the button to display the title of this page</p> <button onclick="myFunction()">Click Me</button> <p id="point"></p> <script> var x = document.getElementById("point"); function myFunction(){ x.innerHTML = document.title; } </script> </body> </html>



Return Values

StringReturns the title of the current document.

Set Title

In the following example, we will set a custom title for the page using JavaScript.


HTML Online Editor
<!DOCTYPE html> <html> <head> <title>Example Page</title> </head> <body> <p>Type any title and click 'submit' button</p> <input type="text" id="myTitle"> <button onclick="myFunction()">submit</button> <script> var x = document.getElementById("myTitle"); function myFunction(){ document.title = x.value; } </script> </body> </html>


Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author