[css4-ui] ::tooltip

A way to style tooltips was discussed in the mailing list 3 years ago 
[1], but no resolution was reached and WG participation was very low. I 
consider this a very useful feature, so I thought I'd bring up the issue 
again. The short 2009 discussion follows (older to newer):

François REMY <fremycompany_pub@yahoo.fr> wrote on Mon, 13 Apr 2009 
12:29:15 +0200:
> This property should have the same effect as the 'title' attribute on XHTML
> documents.
> I propose that because I just have seen that there's no way to emulate this
> attribute in CSS.
>
> What do you think about it ?
>
> Regards,
> Fremy
Tab Atkins Jr. <jackalmage@gmail.com> wrote on Mon, 13 Apr 2009 06:45:02 
-0500:
> How would it work?  I assume something like:
>
> foo { tooltip: "I'm a popup!  Sort of."; }
>
> Is this correct?
>
> ~TJ
François REMY <fremycompany_pub@yahoo.fr> wrote on Mon, 13 Apr 2009 
15:06:05 +0200:
> Yes, it's how the title attribute works (with a string).
> But maybe we can have more options in CSS by adding keywords.
>
> Some ideas we can evaluate :
>
>      [follow-mouse / keep-position (default)]? : Say if the tooltip follow
> the mouse (moves at the same time the mouse moves) or if it stay static
> (normal behavior of a tooltip)
>
>      [<length>  <length>  | auto (default)]? : Position of the tooltip
> relatively to the mouse; negative length are computed as 0px.
>
>      ...
>
> Fremy
Pascal Germroth <pascal@germroth.name>  wrote on Mon, 13 Apr 2009 
15:15:37 +0200:
> I would rather propose a ::tooltip pseudo-element.
> The default would be:
>
> *::tooltip {
>    content: attr(title);
>    color: InfoText;
>    background: InfoBackground;
> }
>
> But if one wants to display the URL and title for a link, in some other
> form:
>
> a[href]::tooltip {
>    content: attr(title) " (" attr(href) ")";
>    color: red; background: white;
> }
>
> This could replace the now used scripts which try to move a box after
> the cursor.
>
> More advanced tooltips could then be realized with:
>
> e>  x|tip { move-to: tt; }
> e::tooltip { content: pending(tt), attr(title); }
>
>
>
> -- 
> pascal
François REMY <fremycompany_pub@yahoo.fr> wrote on Mon, 13 Apr 2009 
15:19:59 +0200:
> Yes, it can be great too.

[1]: http://lists.w3.org/Archives/Public/www-style/2009Apr/0221.html

-- 
Lea Verou (http://lea.verou.me | @LeaVerou)

Received on Wednesday, 11 April 2012 00:05:30 UTC