In a drop down list, I need to add spaces in front of the options in the list. I am trying
<select>
<option>  Sample</option>
</select>
for adding two spaces but it displays no spaces. How can I add spaces before option texts?
In a drop down list, I need to add spaces in front of the options in the list. I am trying
<select>
<option>  Sample</option>
</select>
for adding two spaces but it displays no spaces. How can I add spaces before option texts?
I tried several of these examples, but the only thing that worked was using javascript, much like dabobert's, but not jQuery, just plain old vanilla javascript and spaces:
This is IE only. IE11 in fact. Ugh.
i tried multiple things but the only thing that worked for me was to use javascript. just notice that i'm using the unicode code for space rather than the html entity, as js doenst know a thing about entities
Can you try that? Or is it the same?
As Rob Cooper pointed out, there are some compatibility issues with older browsers (IE6 will display the actual letters "& nbsp;"
This is how I get around it in ASP.Net (I don't have VS open so I'm not sure what characters this actually gets translated to):
I was also having the same issue and I was required to fix this as soon as possible. Though I googled a lot, I was not able to find a quick solution.
Instead I used my own solution, though I am not sure if its appropriate one, it works in my case and exactly which I was required to do.
So when you add an ListItem in dropdown and you want to add space then use the following:-
Press ALT and type
0160
on your numeric keypad, so it should be something likeALT+0160
. It will add a space.Server.HtmlDecode(" ")
is the only one that worked for me.Otherwise the chr are printed as text.
I tried to add the padding as a Attribute for the listitem, however it didnt affect it.