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?
CodePudding user response:
The <option> element, and therefore the select, can only contain text, not images.
CodePudding user response:
<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
é).
Suffice to say that <img> elements for not meet this standard.
