Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html

What is the use of title attribute in HTML?

Abdul Muizz

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

We use the title attribute in HTML to specify the extra information about the element. The additional information appears whenever the mouse hovers over the element.

Note: All HTML tags support this attribute.

Syntax

We'll use the syntax below to add the title attribute to an HTML element:


<element title='text'>


Here element can be any sort of HTML tag , for example, <p>,<a> and <img>, and others.

Example 1

The following code snippet illustrates the use of the title attribute in the h3 tag of HTML:

Use of title attribute in <h3> tag

Explanation

  • Line 5: This line uses the title attribute in a <h3> tag. The result is shown in the output tab of the widget above.
  • The example above shows that the additional information appears when we hover the mouse over the <h3> tag.

Example 2

Similarly, we can make use of the title attribute on <img> tag as well. This is depicted by the code snippet below:

Use of title attribute in <img> tag

Explanation

  • Line 5: This line depicts the use of title attribute in an <img> tag and sets it to the value of Educative Inc.

This answer summarizes the primary use of the title attribute along with code snippets to demonstrate its functionality.

RELATED TAGS

html

CONTRIBUTOR

Abdul Muizz
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring