W3C home > Mailing lists > Public > www-style@w3.org > March 2008

Re: Title attribute and css selectors

From: David Woolley <forums@david-woolley.me.uk>
Date: Sun, 16 Mar 2008 11:50:26 +0000
Message-ID: <47DD0982.10202@david-woolley.me.uk>
To: www-style@w3.org

Lorenzo De Tomasi wrote:
> Is it possible with css to select a visible attribute like title=""
> and apply a new style to it?

I think this is a "how to" question, and therefor off topic, so I 
probably shouldn't answer it.

Conceptually, title is only a visible attribute because your browser ahs 
a style sheet rule that generates an absolutely positioned virtual box 
based on a selector that includes the presence of the attribute and 
:hover status for the parent element.

I'm not sure that CSS is yet capable of actually representing that style 
sheet fragment, but if it were, you would need to either find out what 
the browser's relevant user agent style sheet said and put in 
appropriate overrides for that, or you would need to essentially 
completely redefine that fragment.  The latter is particularly 
undesirable because it may be completely inconsistent with the user's 
browser's way of handling title.

In practice, GUI browsers don't implement title using style sheets but 
either directly use the GUI's tool tip mechanism or simulate IE/Windows 
use of the Windows tooltip mechanism.

Finally note that HTML only requires that the contents of title be made 
available to users to clarify the intent of an element; it doesn't 
mandate how that should be done.  On a non-GUI browser, it would be 
unreasonable, or impossible, to use a popup and the standard handling on 
a GUI one might actually be to display the information in the window or 
screen status area.
> 
> For example, in <a href="http://index.html" title="Go to the
> homepage">Homepage</a>

That's a bad example.  Titles are generally nouns, especially for links, 
so there is no need for "Go to", and the rest of the title adds nothing 
to the link name.  Typically, on a link (used in the role of a link), 
title should be similar to the contents of the title element.

> background-color for the 'title box' that appears when i do a rollover
> on the link or the image (Firefox default is a black text on a yellow
> background box).

Black on yellow is the Windows user interface default for tool tips; I'm 
not sure if Windows allows you to override that, or if it does, whether 
it allows you to override it other than for the whole user interface.

(There have been proposals for making tool tips a specific style, on the 
base element, rather than constructing them from basic principles using 
absolutely positioned generated boxes.  I'm not sure whether those 
proposals are in CSS3 at the moment.)

-- 
David Woolley
Emails are not formal business letters, whatever businesses may want.
RFC1855 says there should be an address here, but, in a world of spam,
that is no longer good advice, as archive address hiding may not work.
Received on Sunday, 16 March 2008 11:51:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:02 GMT