HTML title Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Tooltips & Metadata

Introduction

The title attribute is a global HTML attribute that lets you provide advisory information about an element. On most elements, browsers show this text as a tooltip when the user hovers with a mouse.

It works on links, images, paragraphs, abbreviations, and many other elements. Do not confuse it with the <title> element in the document <head>—that sets the browser tab label and affects SEO.

What You’ll Learn

01

Tooltips

Hover text.

02

Global attr

Most elements.

03

vs <title>

Not the same.

04

abbr

Expansions.

05

JavaScript

el.title.

06

A11y limits

Not primary.

Purpose of title

The primary purpose of the title attribute is to offer supplementary information displayed when a user hovers over an element (typically as a tooltip). It gives extra context without changing the visible page content.

Common uses include explaining abbreviated text on <abbr>, adding hints on icons or truncated labels, and naming embedded frames on <iframe title="..."> for accessibility.

💡
Not for SEO

The title attribute does not improve search rankings. Use the <title> element in <head> for page titles in search results.

📝 Syntax

Add title to any element with a text string:

title.html
<p title="This is a tooltip when you hover.">
  Hover over this paragraph.
</p>

Syntax Rules

  • Global attribute — valid on nearly all HTML elements.
  • Value is a plain text string (no HTML inside the attribute).
  • Tooltips appear on hover for pointer users; behavior varies on touch devices.
  • On <iframe>, title names the frame for assistive technology (required for accessibility).
  • IDL property: HTMLElement.title (empty string removes advisory text).
  • Do not duplicate visible link text in title on anchors.

💎 Values

The title attribute accepts a single string value—any text you want to show as advisory information:

  • title="Save your document" — Hint on a button or icon.
  • title="HyperText Markup Language" — Expansion on <abbr>.
  • title="Product photo: blue running shoes" — Extra detail on an image (not a substitute for alt).
  • title="Customer support chat" — Name for an <iframe>.
title-values.html
<abbr title="World Health Organization">WHO</abbr>

<a href="/docs" title="Read the full documentation (PDF, 2 MB)">Docs</a>

⚡ Quick Reference

TopicDetailExample
FormatPlain text stringtitle="Hint"
DisplayTooltip on hoverMouse users
ScopeGlobal attributeMost elements
JavaScriptelement.titleRead/write string
Not the same as<title> in headBrowser tab / SEO
iframeAccessible nameRequired for a11y

Applicable Elements

ElementTypical use of titleNotes
<abbr>Spell out abbreviationClassic pattern
<a>, <button>Extra hint on hoverDon’t hide essential info
<img>Advisory noteUse alt for accessibility
<iframe>Frame descriptionAccessible name
<p>, <span>, etc.Tooltip textGlobal attribute

title attribute vs <title> element vs alt

FeaturePurposeSEO / A11y
title attributeTooltip / advisory textNot for SEO; limited a11y
<title> elementDocument name in tabImportant for SEO
alt on imgImage replacement textEssential for a11y
aria-labelAccessible nameReliable for screen readers

Examples Gallery

Paragraph tooltip, abbreviation expansion, and dynamic JavaScript updates.

👀 Live Preview

Hover over the text below to see the tooltip:

Hover me for a title tooltip

Example — paragraph with title

Basic tooltip on a paragraph:

title.html
<p title="This is a tooltip message when you hover over this paragraph.">
  This is a paragraph with a title attribute.
</p>
Try It Yourself

How It Works

The title attribute on the paragraph provides a tooltip when the user hovers over it. The visible text stays unchanged.

Example — abbreviation expansion

A practical use on <abbr>:

abbr-title.html
<p>
  The <abbr title="HyperText Markup Language">HTML</abbr>
  title attribute shows the full form on hover.
</p>

How It Works

Readers see “HTML” but hovering reveals the full phrase. Include the expansion in visible text when possible for keyboard-only users.

Dynamic Values with JavaScript

Update tooltip text at runtime:

dynamic-title.html
<p id="dynamicParagraph">
  This paragraph will have a dynamically set title attribute.
</p>

<script>
  document.getElementById("dynamicParagraph").title = "Updated tooltip message.";
</script>

How It Works

In this script, the title for the paragraph with id dynamicParagraph is set after the page loads. Useful when tooltip content depends on live data or user state.

♿ Accessibility

  • Do not rely on title alone — Many screen readers ignore or inconsistently announce title tooltips. Put essential information in visible text.
  • Use alt on images — Not title — for meaningful image descriptions.
  • Always set title on iframes — It provides the accessible name of the embedded frame.
  • Avoid duplicate link text — Repeating the same words in title on <a> adds noise for some assistive tech.
  • Keyboard and touch users — Tooltips may not appear without a mouse; never hide critical instructions in title only.

🧠 How title Works

1

Author adds text

title string.

HTML
2

User hovers

Pointer device.

Input
3

Browser shows tip

Native tooltip.

UI
=

Extra context

On hover.

Browser Support

The title attribute is universally supported. All major browsers display native tooltips for title on hover (timing and styling vary).

Universal · Fully supported

Works everywhere

Chrome, Firefox, Safari, and Edge all honor the title attribute.

100% Modern browsers
Google Chrome All versions
Supported
Mozilla Firefox All versions
Supported
Apple Safari All versions
Supported
Microsoft Edge All versions
Supported
title attribute Excellent

Bottom line: Tooltip support is reliable; do not depend on it for critical accessibility information.

💡 Best Practices

✅ Do

  • Use concise, relevant tooltip text
  • Put expansions on <abbr> with title
  • Always set title on <iframe> elements
  • Keep essential info in visible page content
  • Test tooltip behavior across browsers

❌ Don’t

  • Confuse title attribute with <title> element
  • Expect title to improve SEO
  • Replace alt on images with title
  • Write long, intrusive tooltip paragraphs
  • Hide instructions only in tooltips

Conclusion

The title attribute is a useful way to offer supplementary information through native tooltips without cluttering visible content. Applied thoughtfully on abbreviations, icons, and frames, it improves clarity for pointer users.

Remember the limits: it is not for SEO, not a replacement for accessible names, and not visible to all users. Pair it with visible text and proper semantic HTML for the best experience.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about title

Bookmark these when adding tooltips.

5
Core concepts
🌐 02

Global

Most elements

Scope
📄 03

Not <title>

Different feature

Clarify
⚙️ 04

el.title

JavaScript

Dynamic
05

Not for SEO

Advisory only

Limits

❓ Frequently Asked Questions

It provides advisory text, usually shown as a tooltip on hover.
No. The attribute adds tooltips. The <title> element in <head> sets the browser tab title.
No. Search engines use the document <title> element, not body element title attributes.
Yes. Assign to element.title, for example p.title = "New hint".
No. Use alt for accessible image descriptions. title is optional advisory text only.
It names the embedded frame so screen reader users know what the iframe contains.

Try a tooltip yourself

Hover over the paragraph in the editor to see the title attribute in action.

Try paragraph tooltip →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful