Adding HTML within an image title attribute

First of all i’d recommend you stop using title attribute for html container purpose:

Image title (and the element name speaks for itself) should provide
additional information and follow the rules of the regular title: it
should be relevant, short, catchy, and concise (a title “offers
advisory information about the element for which it is set“). In
FireFox and Opera it pops up when you hover over an image

In order to get things works you can use data- attribute (very good “intermediate” article about data-attribute with example how to use)

Considering [Can data-* attribute contain HTML tags?] it’s valid to use data- attributes with HTML, and, as recommended under the refference above – take into account character escape.

Leave a Comment