X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML DOM title Property

HTMLElement Object Reference Element Object

Definition and Usage

The title property sets or returns the element's advisory title.

Syntax

HTMLElementObject.title=title


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The title property is supported in all major browsers.


Examples

Example 1

Return the title attribute of the body element:

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

<script>
var x=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 yourself »

Example 2

Return the advisory title of an area in an image-map:

<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>
var x=document.getElementById('venus')
document.write(x.title)
</script>
</p>

</body>
</html>

Try it yourself »


HTMLElement Object Reference Element Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook