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

August 28, 2021 - 1 min read

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";

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 😃.