user8937225
user8937225

Reputation: 27

tooltip for select in html

I have a list of car that can be selected from dropdown as

<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

this code gives me code of dropdown, I need a hover message as "select your car" on hovering on the box. There is a option of select that gives message for each option, however my need is to display tooltip only when hovering the select box.

Upvotes: 0

Views: 3407

Answers (1)

AaronHolland
AaronHolland

Reputation: 1685

The easiest way is to add a title attribute:

<select title="Select your car">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="opel">Opel</option>
    <option value="audi">Audi</option>
</select>

It doesn't look that great though. If you want a fancier tooltip you'd have to go the JavaScript route.

Upvotes: 2

Related Questions