I’m currently programming a html (php) menu where I want to use tooltips for the buttons.
As I want to use the form to transmit to me which button has been clicked (via method=POST) i don’t use but instead .
My problem here is that I’m not sure what the best way is to create those tooltips (especially as I want the text to be dynamic……as I plan to use localization in the
future. Thus using images is out of the question there ).
I know how to use tooltips in combination with , but as indicated I’m not sure
what the best way is to use tooltips in combination with buttons.
Example sourcecode (as a note here I’m using a sessionvariable to see what language
the user has):
<input type='button' value="<?php translate('Messages');?>" class='messages'>
<input type='button' value="<?php translate('Logout');?>" class='logout'>
Tnx for all help there
The HTML5 spec defines a set of global attribute which almost all elements support. This includes the
titleattributes which in the specification is for storing additional information about the element. So you can dynamically output the tooltip text into thetitleattribute which will appear on rollover without and need for JavaScript. It also makes the text easily accessible if you choose to use JavaScript to extract the text and output it in a custom styled tooltip.Hope this makes sense.