Which attribute to take for a tooltip text

S

Stefan Mueller

I'd like to add a tooltip text to one word within a sentence.

With the attribute <b>...</b> it works perfect but the word gets bold:
What is <b title = "It's a planet">Pluto</b>?

With the attribute <div>...</div> the word doesn't get bold but there is a
line break:
What is <div title = "It's a planet">Pluto</div>?

Is there an attribute I can use only to add a tooltip text to a word?
Stefan
 
E

Els

Stefan said:
I'd like to add a tooltip text to one word within a sentence.

With the attribute <b>...</b> it works perfect but the word gets bold:
What is <b title = "It's a planet">Pluto</b>?

With the attribute <div>...</div> the word doesn't get bold but there is a
line break:
What is <div title = "It's a planet">Pluto</div>?

Is there an attribute I can use only to add a tooltip text to a word?
Stefan

<span title="It's a dog">Pluto</span>
 
D

Dylan Parry

As if the love poetry wasn't enough, Stefan Mueller just had to say:
With the attribute <b>...</b> it works perfect but the word gets bold:

What were you expecting it to do?
With the attribute <div>...</div> the word doesn't get bold but there is a
line break:

That's because said:
Is there an attribute I can use only to add a tooltip text to a word?

You're on the right path using the /title/ attribute[1] but you are
probably looking for something like the <span> element if you want
nothing else to happen to the text.

What exactly are you trying to do though? Show us an example of the text
to which you wish to add the tooltip, and we may be able to suggest a
better way of doing it.

_____
[1] Note that /title/ is an attribute, but <b> and <div> are elements,
not attributes.
 
B

Barbara de Zoete

I'd like to add a tooltip text to one word within a sentence.

With the attribute <b>...</b> it works perfect but the word gets bold:
What is <b title = "It's a planet">Pluto</b>?

Wel, yeaheh, that is what bold is supposed to do, isn't it.
BTW: what you call attributes are in fact elements and the way you note
them down ( said:
With the attribute <div>...</div> the word doesn't get bold but there is
a line break:
What is <div title = "It's a planet">Pluto</div>?

That is because the div is a block level element. What you need is an
inline element. >
Is there an attribute I can use only to add a tooltip text to a word?

The generic inline element (if there is nothing more appropriate
available) is a span:
<URL:http://www.w3.org/TR/html401/struct/global.html#edef-SPAN>

Don't forget to style the span so visitors can see that the word has a
tooltip. I would do it something like:

markup:
What is <span class="answer" title="It is a planet">Pluto</span>?

styles:
span.anwer {
cursor:help;
border-bottom:1px dotted blue; }

It is doubtful we will regard Pluto a planet in some time from now btw,
but that is an entirely different matter :)

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
 
S

Stefan Mueller

markup:
What is <span class="answer" title="It is a planet">Pluto</span>?

styles:
span.anwer {
cursor:help;
border-bottom:1px dotted blue; }

Wow, this is even better than expected. Very nice hint also to change the
cursor.

Many thanks
Stefan
 
A

Alan J. Flavell

The generic inline element (if there is nothing more appropriate available) is
a span:

Yes. But if there is something more-specific available, one should
use it. Although it's not very appropriate to your specific example,
there are situations where <dfn>, <abbr> or <acronym> could be
appropriate, which is why this appears:

abbr, acronym, dfn, .abbr { border: 1px dotted #666;
background-color: #eee; color: #030;
border-top: none; cursor: help; }

in my stylesheet. The reason for the ".abbr" is that when I'm
in a good mood, I do abbreviations like this:

<span class="abbr" title="whatever"><abbr
title="whatever">...</abbr></span>

for the benefit of a certain back-level operating system component
that thinks it's a browser. When I'm feeling crabby, I just use
<abbr> and leave the span off, on the grounds that those who chose the
back-level software are getting what they paid for.

cheers

yes, I could simplify that border stuff now, but specifying the
border and the border-top separately was a workaround for some
ancient browser bug.
 
S

Stefan Mueller

Oh, life can be so hard.
Mozilla seems to support only something like a tooltip length of 85
charaters :-(

Stefan
 
M

Mark Parnell

Mozilla seems to support only something like a tooltip length of 85
charaters :-(

It depends on what the text is (will be less if lots of wide
characters), but it's generally around 100 characters IME.
 
N

Neredbojias

With neither quill nor qualm, Barbara de Zoete quothed:
It is doubtful we will regard Pluto a planet in some time from now btw,
but that is an entirely different matter :)

Why? The Pluto-Charon system may or may not be a captured object but it
is a planet nonetheless.
 
D

dorayme

From: "Stefan Mueller said:
Oh, life can be so hard.
Mozilla seems to support only something like a tooltip length of 85
charaters :-(

Stefan

.... it sort of cruels all possible projects to have orders of mag bigger
tooltip help popouts than the actual text...
 
M

Mark Parnell

It depends on what the text is (will be less if lots of wide
characters), but it's generally around 100 characters IME.

Anything longer than that is too long to be appropriate for a tooltip
anyway.
 
D

dorayme

From: Neredbojias said:
With neither quill nor qualm, Barbara de Zoete quothed:


Why? The Pluto-Charon system may or may not be a captured object but it
is a planet nonetheless.

....depends on what a planet is... It is not good enough maybe
that it goes round and round and influences a few things and has
been believed to be a planet...

You been all goody goody two shoes and now out of the DZ
killfile eh? I miss your screaming down in the lower chamber....
 
N

Neredbojias

With neither quill nor qualm, Mark Parnell quothed:
Anything longer than that is too long to be appropriate for a tooltip
anyway.

Agreed. I was going to add that but too lazy to post it.

Anyone else besides me annoyed by the Opera behavior on images?
 
N

Neredbojias

With neither quill nor qualm, dorayme quothed:
...depends on what a planet is... It is not good enough maybe
that it goes round and round and influences a few things and has
been believed to be a planet...

Yes, I s'pose it depends on your exact definition of "planet". In my
universe, galaxy, solar system, however, it's a planet.
You been all goody goody two shoes and now out of the DZ
killfile eh? I miss your screaming down in the lower chamber....

Dunno, but notice that she's been nicer of late (-ok, too...) I'll
admit that maybe sometimes I get slightly too exuberant with my jokes
but proging all day long requires some release.
 
J

Jukka K. Korpela

Dylan Parry said:
You're on the right path using the /title/ attribute

I doubt that.

It is supposed to specify an advisory title. In practice, most people will
see a tooltip if they happen to mouse over the word. So what? Many of them
will be puzzled. Many people won't see the tooltip, or will see it in too
tiny a font (no, _you_ can't set the font size of tooltips, except on your
own computer, and most people don't know about this). Many people who could
see it won't see since they have no reason to move around with the mouse, or
maybe they have no mouse.

If it's anything essential, it should be served in a much more reliable way.
If it isn't, why would you include it?

The title attribute might be suitable for special occasions. Most authors
simply cannot use it properly, and should stay away from it, except perhaps
for links.
 
D

dorayme

From: Neredbojias said:
With neither quill nor qualm, dorayme quothed:


Yes, I s'pose it depends on your exact definition of "planet". In my
universe, galaxy, solar system, however, it's a planet.

I knew it! You are happy to be in a different universe to the
rest of us!

Dunno, but notice that she's been nicer of late (-ok, too...) I'll
admit that maybe sometimes I get slightly too exuberant with my jokes
but proging all day long requires some release.

Yes, I have noticed that. The reason is simple you know: she
takes a peek every now and then at the various bods she has all
locked up in her killfile chambers. She figures she must not be
any worse than the best of them. This lifts her to a higher
plane of existence judging by the absolutely sweet and gentle
nature of some of the folks I have met down there...

(Hey, Boji, I know this has nothing to do with css/html but are
you sure you're not Martian? I get the feeling I saw you around
up there? You got a kink about 35mm down on your left antenna?)
 
N

Neredbojias

With neither quill nor qualm, dorayme quothed:
I knew it! You are happy to be in a different universe to the
rest of us!

Although admitting to nothing, I figure that _if_ I happen to be in an
antimatter universe, it can only anti-matter which means it doesn't
matter at all. Of course, sparks would fly upon contact with this area
of the traditional universe said:
Yes, I have noticed that. The reason is simple you know: she
takes a peek every now and then at the various bods she has all
locked up in her killfile chambers. She figures she must not be
any worse than the best of them. This lifts her to a higher
plane of existence judging by the absolutely sweet and gentle
nature of some of the folks I have met down there...

Only the good die young? Perhaps not everybody in anybody's killfile
has a truly sweet and gentle nature.
(Hey, Boji, I know this has nothing to do with css/html but are
you sure you're not Martian? I get the feeling I saw you around
up there? You got a kink about 35mm down on your left antenna?)

Nah, my antenna isn't kinky and Mars is too cold for me, anyway.
Sometimes, however, I practice water sharing, particularly when I've
just purchased a new squirt gun. Grok this, the other day I saw a very
devout Saturnian with a halo doing pirouettes at an ice rink. Talk
about dizzy.
 
J

Jukka K. Korpela

Dylan Parry said:
You're on the right path using the /title/ attribute

I doubt that.

It is supposed to specify an advisory title. In practice, most people will
see a tooltip if they happen to mouse over the word. So what? Many of them
will be puzzled. Many people won't see the tooltip, or will see it in too
tiny a font (no, _you_ can't set the font size of tooltips, except on your
own computer, and most people don't know about this). Many people who could
see it won't see since they have no reason to move around with the mouse, or
maybe they have no mouse.

If it's anything essential, it should be served in a much more reliable way.
If it isn't, why would you include it?

The title attribute might be suitable for special occasions. Most authors
simply cannot use it properly, and should stay away from it, except perhaps
for links.
 
B

bernhard

Jukka said:
I doubt that.

It is supposed to specify an advisory title. In practice, most people will
see a tooltip if they happen to mouse over the word. So what? Many of them
will be puzzled. Many people won't see the tooltip, or will see it in too
tiny a font (no, _you_ can't set the font size of tooltips, except on your
own computer, and most people don't know about this). Many people who could
see it won't see since they have no reason to move around with the mouse, or
maybe they have no mouse.

If it's anything essential, it should be served in a much more reliable way.
If it isn't, why would you include it?

The title attribute might be suitable for special occasions. Most authors
simply cannot use it properly, and should stay away from it, except perhaps
for links.
This is what the specification says:
http://www.w3.org/TR/html4/struct/global.html#adef-title

It's also worth to note, that FF, NN and Opera display the <abbr> and
<acronym> elements with the title attribute set, underlined with a gray
dotted line; enough reason to move the mouse over those elements ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top