Skip to content

The title Attribute

Global Attribute

The title attribute provides advisory information about an element, typically displayed as a tooltip when the user hovers over it. It’s commonly used to add extra context, descriptions, or explanations for elements.

<element title="Descriptive text">Content</element>
ValueDescription
textText that describes or provides additional information about the element
Result
Result
Result
Result
Result
Result
Result
Result
<!-- Good: Brief and informative -->
<button title="Save changes">💾</button>
<a href="#" title="Download PDF version">Download</a>
<!-- Avoid: Too verbose -->
<button title="Click this button to save all of your changes to the database">💾</button>
<!-- Avoid: Title repeats visible text -->
<a href="#" title="Learn More">Learn More</a>
<!-- Better: Title adds new information -->
<a href="#" title="Opens documentation in new window">Learn More</a>
<!-- Or omit if no additional info -->
<a href="#">Learn More</a>
<!-- Good: Adds context -->
<time datetime="2024-01-15" title="January 15, 2024 at 2:30 PM EST">
Yesterday
</time>
<span title="Based on 1,234 reviews">★★★★☆ 4.5</span>
<!-- Essential for icon-only buttons -->
<button title="Delete item">🗑️</button>
<button title="Edit details">✏️</button>
<button title="Share">📤</button>

The title attribute is not accessible on images for screen readers:

<!-- Wrong: Title is not read by screen readers for images -->
<img src="logo.png" title="Company Logo">
<!-- Correct: Use alt attribute -->
<img src="logo.png" alt="Company Logo">
<!-- Optional: Both can be used together -->
<img src="logo.png" alt="Company Logo" title="Click to return to homepage">

Tooltips only appear on hover, making them inaccessible to keyboard users:

<!-- Problem: Keyboard users can't see the tooltip -->
<span title="Additional information">Help</span>
<!-- Better: Use visible text or ARIA -->
<button aria-describedby="help-text">Submit</button>
<div id="help-text">Click to submit the form</div>
<!-- Or make it visible -->
<span>Help <small>(Additional information)</small></span>

Tooltips don’t work well on touch devices:

<!-- Consider mobile users -->
<button title="This won't show on mobile">
ℹ️ Info
</button>
<!-- Better: Use visible text or modals -->
<button onclick="showInfo()">
ℹ️ Info
</button>

For accessibility, prefer ARIA attributes:

<!-- Title alone (not always accessible) -->
<button title="Close dialog">×</button>
<!-- Better: Use aria-label -->
<button aria-label="Close dialog">×</button>
<!-- Both can be used together -->
<button aria-label="Close dialog" title="Close (Esc)">×</button>
Result

For more control, create custom tooltips:

Result

The title attribute is supported by all browsers.

BrowserSupport
ChromeAll versions
FirefoxAll versions
SafariAll versions
EdgeAll versions