Previous Message
Next Message

Styling the title attribute

Sent by Eric A. Meyer on 2 February 2005 16:04


At 15:34 +0000 2/2/05, Andrea Fiore wrote:

>Css2 allows the selection of attributes, and not only elements of 
>the document; so is it possible to style the title propriety of a 
>link?

    Actually, what CSS2 allows is the selection of element based on 
their attributes.  You can't directly select an attribute in CSS.  In 
your case:

>a.class_name[title] {
>  color: red;
>}

    ...that will turn red the contents of any 'a' element with a 
'class' attribute whose value contains the word 'class_name' and 
which has a 'title' attribute, regardless of the attribute's value. 
(And I wrote that all out without even using the SelectORacle!)
    So the result is red link text, not red "tooltip" text.  CSS 
doesn't offer a way to style things like "tooltips", which are UI 
features.  You might be able to simulate tooltips using one or 
another of the popup solutions, and then style the popups.
    Also, by using an attribute selector, you're leaving IE/Win out of 
the game, since it doesn't natively understand attribute selectors. 
If you're still willing to experiment, though, you could try:

    a.class_name[title] {position: relative;}
    a.class_name[title]:hover:after {content: attr(title);
     position: absolute; left: 50%; top: 0.5em; width: 10em;
     font-size: smaller; border: 1px solid;
     background: yellow; color: red;}

It's an off-the-cuff idea, so it may need some adjustment, but try it 
out in Firefox and see what happens.

-- 
Eric A. Meyer (http://meyerweb.com/eric/), List Chaperone
"CSS is much too interesting and elegant to be not taken seriously."
   -- Martina Kosloff (http://mako4css.com/)
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread:

Possibly related: