RE: Title attribute and css selectors

Brad,

One question that needs to be answered is whether or not the <title> is 'text'.

Being found within the <head> element, which is composed of a lot of non-text types of things, it really is not reasonable to consider that the <title> is not for styling purposes...or it might have been included in the <body> portion of the document.

The title is normally displayed outside of the context of the body or the client window where the content is rendered. Perhaps Linux, or some other OS, wants to allow for any application to style their windowing system. That is, however, outside of the scope of the CSS specification and should never be considered normative.

Paul


-----Original Message-----
From: www-style-request@w3.org [mailto:www-style-request@w3.org] On Behalf Of Brad Kemper
Sent: Monday, March 17, 2008 12:27 AM
To: David Woolley
Cc: www-style@w3.org
Subject: Re: Title attribute and css selectors



On Mar 16, 2008, at 4:50 AM, David Woolley wrote:

>
> 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.

Undesirable? So? Authors have the power to control what text, if any,
is used in the title attribute, or can leave it blank and generate
pseudo-tooltips of their own using some other means. It may be
undesirable for you, but fortunately authors do not need to consult
you before implementing their choices.

I don't think it is unreasonable to follow the same pattern of
allowing some restyling of UI elements, and suggest that UAs start
implementing tooltips in a way that allows authors to restyle them.
You wouldn't need to know the browser's default style sheet. It would
presumably look something like this:

*[title]:not([title=""):before { content: attr(title);
appearance:tooltip }

The appearance would include position information, color, font,
opacity, box-shadow, etc. Then if an author had a mostly yellow
layout, and wanted the tooltip to stand out against it better, the
author could change the background color or thicken the border in
page's style sheet:

*[title]:not([title=""):before { background-color: purple; border-
width:3px; }


> 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.

All the more reason not to discourage authors from using the title
attribute for their hand-rolled tool-tips (currently, an all-CSS
solution using the title attribute for the content results in 2
tooltips: the author's styled version, and the automatic UI one).

>> 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.

I think that is a "how to write title tags" answer, and therefor off
topic.

>> 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 20:16:34 UTC