DEV Community

Discussion on: 3 Insanely Simple Steps To DIY Tooltips

Collapse
 
4shub profile image
Shubham Naik • Edited

I would say that you should rename the tooltip-title attribute to data-tooltip-title the general HTML spec doesn't like when sites implement custom attributes that aren't prepended by a data-.

This is because not all browsers work with custom attributes as intended, older browsers might not be able to understand attributes that aren't explicitly defined in the w3c spec unless placed with data-. Placing data- also future proofs browsers as if there is any change in the future where tooltip-title becomes an accepted standard in HTML, this implementation would break.

More information here:
[1] w3.org/TR/2011/WD-html5-20110525/e....

[2] developer.mozilla.org/en-US/docs/W...

Collapse
 
vishnubaliga profile image
Vishnu Baliga

Thank you for pointing that out. As you said, it is always good to use a custom data attribute.

In the DIY examples mentioned above, I wanted to keep it simple and easy to understand. They can always have their own way of defining the attributes.