Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML DOM title property


May 06, 2021 JavaScript with HTML DOM Reference book


Table of contents


HTML DOM title property

HTML DOM title property The element object


Definitions and usages

The title property sets or returns the title of the element.

Grammar

HTMLElementObject.title= title


Browser support

HTML DOM title property HTML DOM title property HTML DOM title property HTML DOM title property HTML DOM title property

The title property is supported by all major browsers


Instance 1

Returns the title property of the body element:

<html>
<body id="myid" title="mytitle">

<script>
varx=document.getElementsByTagName('body')[0];
document.write("Body title: " + x.title);
document.write("<br>");
document.write("An alternate way: ");
document.write(document.getElementById('myid').title);
</script>

</body>
</html>

Output:

Body title: mytitle
An alternate way: mytitle

Try it out . . .

Instance 2

Return to the area map title in the image:

<html>
<body>

<img src ="planets.gif"
width="145" height="126"
alt="Planets"
usemap ="#planetmap">

<map name ="planetmap">
<area id="venus" shape="circle"
coords ="124,58,8"
title="Venus"
href ="venus.htm">
</map>

<p>Venus' advisory title (mouse over the Venus planet):
<script>
varx=document.getElementById('venus')
document.write(x.title)
</script>
</p>

</body>
</html>

Try it out . . .


HTML DOM title property The element object