HTML <span> title Attribute

The title attribute on a <span> tag adds a tooltip with title text to the span element. Hovering the mouse over the span element will display the tooltip.

Example

#

A title attribute on a <span> element.

Did you know? The Great Pyramid of Giza was the tallest building in the world for over 3,800 years, until the construction of the Lincoln Cathedral in the UK in 1311.

<article>
  <p style="max-width:610px;">
    Did you know? The Great Pyramid of Giza was the tallest building in the world
    for <span title="the great pyramid of giza">over 3,800 years</span>, 
    until the construction of the Lincoln Cathedral in the UK in 1311.
  </p>
</article>

Code explanation

The title attribute is placed in the <span> opening tag.

The value can be any string.

Hover the cursor over the <span> and after a second a tooltip appears.


Using title

The title attributes attaches additional information to the <span> element.

The title attribute value can be seen as tooltip.

The tooltip displays when the <span> element is hovered.


Syntax

<span title="value">

Values

#

Value Description
value A string value.
A title can span multiple lines by including newline or carriage-return characters:  &#10;  or  &#013;.

Browser support

Here is when title support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <span>
Guides