Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding images with option tag [duplicate]

Tags:

html

css

I have a drop down list. I want to add images along with it. I tried adding img tag inside tha option tag... But still the images are not getting displayed. How do I do it using option tag?

like image 576
enthusiastic Avatar asked Apr 06 '11 06:04

enthusiastic


1 Answers

It's not possible, as <option> only supports text.

You may have to roll your own drop-down control using complex HTML/CSS/JavaScript. How to do it may or may not be within the scope of your question.

Alternatively, you may use a non-repeating background-image and apply some padding on the text to achieve a similar effect. But if each <option> is to have a unique image, your code is going to be polluted with a style attribute for every single <option>. If you don't mind that, it's fine. Otherwise, roll your own somehow.

like image 56
BoltClock Avatar answered Sep 23 '22 13:09

BoltClock