/

HTML / CSS / JavaScript Tutorial

HTML Element: <title>

[this page | pdf | back links]

The HTML <title> element indicates the title for the document. It appears in the <head> part of the document. It typically identifies the page title that appears in a browser toolbar, the page title that is by default added to a user’s list of favourite pages within a browser and usually is the title shown for the page in search engine results.

 

The attributes it can take are HTML global attributes and HTML event attributes.

 

To create or access such an element in JavaScript see here. The corresponding HTML DOM object supports standard DOM properties and methods. It also supports the following additional properties:

 

Property

Description

More

text

Sets / returns text of document title

Here

 

The default style applicable to this element is shown here.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<title>Title Element</title>
</head>
<body>
Created using HTML:<br>
<span>webpage has title created by HTML</span>

<br><br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var x = document.getElementsByTagName("TITLE")[0]
var s = x.text;
var s2 = document.title
document.getElementById("element").innerHTML = 'which is "' + s + '"'
  + '<br>or (using a different way of accessing the title) "' + s2 +'"';
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Elements


Desktop view | Switch to Mobile