2

Can I add title attribute for "a" element in HTML5? The spec does not mention title attribute for "a" element here http://www.w3.org/TR/html-markup/a.html, so for example, would it be valid to use

<a title="mylink" href="...
  • 1
    How can a tag have another tag? You'll need to clarify your question. – John Conde Jul 22 '14 at 11:38
  • Note that w3.org/TR/html-markup is not the spec. It’s only a non-normative reference (and now discontinued on top of that). The W3C HTML5 spec is w3.org/TR/html5. See my answer on SO on how to find which attributes are defined for an element. – unor Aug 14 '14 at 15:03
2

The title attribute is available to all HTML tags:

HTML defines a few attributes that are common to all HTML elements. These attributes can be used on all elements, though the attributes may have no effect on some elements.

So you can safely put it on any element you want. But it is up to the browser to determine if it will do anything with that information. Having said that, you can safely count on all major browsers showing a tooltip of some kind for the title attribute on a a tag.

1

Title is common to all elements: http://www.w3.org/TR/html-markup/global-attributes.html#global-attributes

However, it is worth paying notice of the warning on this page: http://www.w3.org/html/wg/drafts/html/master/dom.html#the-title-attribute

Relying on the title attribute for the visual display of text 
content is currently discouraged as many user agents do not expose 
the attribute in an accessible manner as required by this 
specification (e.g. requiring a pointing device such as a mouse 
to cause a tooltip to appear, which excludes keyboard-only users 
and touch-only users, such as anyone with a modern phone or tablet).
  • Much appreciated, this is a good answer too. I would accept it if I could two answers. – giorgio79 Jul 22 '14 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.