into in an HTML page? use javascript or some other method? have any recom...">

What's a good way to insert <img src = "..." /> into <parameter> </option> in an HTML page?

use javascript or some other method? have any recommendations?

+2


source to share


3 answers


IMAGE ID cannot be within OPTION one (as per HTML4.01 and XHTML1.0). Apply it as a background image (of an option item).

...
<option style="background-image:url(...) ...">...</option>
...

      



Also note that some browsers do not allow for much styling of select and options. For example Safari doesn't support "background-color" on option elements (there's a WebKit bug filed back in '06 :))

I've heard that Chrome has similar "problems".

+5


source


I would recommend that you use CSS. For example:



<select style="width: 100px;">
<option style="background-image: url(/images/a.png);">First option</option>
<option style="background-image: url(/images/b.png);">Second option</option>
</select>

      

+5


source


Instead, you can use fontAwesome to show some "img". For example, using & # xF046 can display a checkbox image. It's better than nothing. Or you can edit the font to show a simple image.

0


source







All Articles