HTML Standard attribute: title
[this page | pdf | back links]
The HTML title attribute specifies extra
information about an element. Often, if you move the mouse over an element with
its title set then the title typically appears as tooltip text next to the
element.
In HTML 5 this attribute
can be applied to any element.
Valid attribute
values include:
Value
|
Description
|
text
|
Tooltip text relating
to element
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Move mouse over italicised text<br><br>
Created using HTML:<br>
<em title="an example of a title, i.e. tooltip">Here</em>
<br><br>Created using JavaScript:<br>
<span id="element"></span><br>
<span id="element2"></span>
<script>
var x = document.createElement("EM");
var txt = document.createTextNode("Here");
x.appendChild(txt);
var att = document.createAttribute("title");
att.value = "another example of a title, i.e. tooltip";
x.setAttributeNode(att);
document.getElementById("element").appendChild(x);
var x2 = document.createElement("EM");
var txt2 = document.createTextNode("Or here");
x2.appendChild(txt2);
x2.title="yet another example of a title, i.e. tooltip";
document.getElementById("element2").appendChild(x2);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes