-1

for some reason my image won't display in my select option.

<select>
   <option><img src="img/pic1.png" style="height:16px;width:16px;margin-left:4px">Option 1</option>
   <option><img src="img/pic1.png" style="height:16px;width:16px;margin-left:4px">Option 2</option>
   <option><img src="img/pic1.png" style="height:16px;width:16px;margin-left:4px">Option 3</option>
</select>

(Code simplified to understand problem, however, there are no special CSS arguments etc. for the options)

I already searched up other forums and questions on Stackoverflow, but why doesn't it work for me? What do I wrong?

2 Answers2

0

The <option> element, and therefore the select, can only contain text, not images.

Ian Devlin
  • 18,092
  • 5
  • 56
  • 71
0

<option>’s specification does not permit the use of non-textual information in its definition. MDN’s page for <option> spells this out pretty clearly:

Permitted content

Text, possibly with escaped characters (like &eacute;).

Suffice to say that <img> elements for not meet this standard.

esqew
  • 39,199
  • 27
  • 87
  • 126