[英]Image won't display in select option (HTML)
for some reason my image won't display in my select option.由于某种原因,我的图像不会显示在我的 select 选项中。
<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) (代码简化以理解问题,但是,选项没有特殊的 CSS arguments 等)
I already searched up other forums and questions on Stackoverflow, but why doesn't it work for me?我已经在 Stackoverflow 上搜索了其他论坛和问题,但为什么它对我不起作用? What do I wrong?我错了什么?
The <option>
element, and therefore the select, can only contain text, not images. <option>
元素,因此 select 只能包含文本,不能包含图像。
<option>
's specification does not permit the use of non-textual information in its definition. <option>
的规范不允许在其定义中使用非文本信息。 MDN's page for <option>
spells this out pretty clearly: MDN 的<option>
页面非常清楚地说明了这一点:
Permitted content允许的内容
Text, possibly with escaped characters (like
é
).文本,可能带有转义字符(如é
)。
Suffice to say that <img>
elements for not meet this standard.可以说<img>
元素不符合这个标准。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.