DEV Community

Cover image for How to change or add text to the browser tab using JavaScript?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

How to change or add text to the browser tab using JavaScript?

Originally posted here!

To change or add a text to the browser tab, we can set the value of the title property of the global document object to the text we need to show in the browser tab using JavaScript.

For example, consider we want to show a text called Home in the browser tab when the user visits the home page of your website.

So for that, we can use the document.title property and set its value to the string Home.

It can be done like this,

// Change or add text to the browser tab
// using the document.title property
document.title = "Home";
Enter fullscreen mode Exit fullscreen mode

Now the browser tab text will be changed to the text Home.

See the above code live in JSBin.

That's all 😃!

Feel free to share if you found this useful 😃.


Top comments (0)