如何在HTML选择元素中的选项文本之前放置空格字符? [英] How do I put a space character before option text in a HTML select element?

查看:125
本文介绍了如何在HTML选择元素中的选项文本之前放置空格字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下拉列表中,我需要在列表中的选项前添加空格。我正在尝试

 < select> 
< option>&#32&#32;样本< / option>
< / select>

用于添加两个空格,但不显示空格。如何在选项文本之前添加空格?

解决方案

不是&#160 空间实体?

 < select> 
< option>&#160; option 1< / option>
< option>选项2< / option>
< / select>

适合我...

编辑:



刚刚检查了这个,在那些旧版本的浏览器中可能存在兼容性问题,但在我看来,这一切似乎都适合我。只是觉得我应该让你知道,因为你可能想用& nbsp;

替换

In a drop down list, I need to add spaces in front of the options in the list. I am trying

<select>
<option>&#32;&#32;Sample</option>
</select>

for adding two spaces but it displays no spaces. How can I add spaces before option texts?

解决方案

Isn't &#160 the entity for space?

<select>
<option>&#160;option 1</option>
<option>    option 2</option>
</select>

Works for me...

EDIT:

Just checked this out, there may be compatibility issues with this in older browsers, but all seems to work fine for me here. Just thought I should let you know as you may want to replace with &nbsp;

这篇关于如何在HTML选择元素中的选项文本之前放置空格字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆