![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM title Property
The HTML DOM title property returns/sets a string corresponding to the value of the title attribute of a HTML element. The title value shows up when hovering over HTML element.
Following is the syntax −
Returning string value
ElementOfHTMLObject.title
Set title to a string value
ElementOfHTMLObject.title = string
Example
Let us see an example of HTML DOM title property −
<!DOCTYPE html> <html> <head> <title>HTML DOM title</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>HTML-DOM-title</legend> <input type="text" id="textSelect" title="" > <input type="button" onclick="getTitle()" value="Better define the above field"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var textSelect = document.getElementById("textSelect"); function getTitle() { if(textSelect.title === ''){ divDisplay.textContent = 'Details defined now! Please hover over field'; textSelect.title = 'Full Name Expected'; } } </script> </body> </html>
Output
Before clicking ‘Better define the above field’ button −
After clicking ‘Better define the above field’ button −
Advertisements