How to get the title of HTML page with JavaScript?

ZA. picture ZA. · Jun 29, 2009 · Viewed 202.3k times · Source

How can I get the title of an HTML page with JavaScript?

Answer

ZA. picture ZA. · Jun 29, 2009

Use document.title:

console.log(document.title)
<title>Title test</title>

MDN Web Docs