Results 1 to 2 of 2

Thread: How to add white space to the option text

  1. #1
    Join Date
    Sep 2006

    How to add white space to the option text

    How to add white space(s) to the option text?

    <select id="sel">
    <option value=""></option>

    var text ="abc xyz";
    var value ="val";
    var contrlObj = document.getElementById("sel");
    var newOpt = new Option(text,value);
    contrlObj.options[0] = newOpt;


    No matter how many spaces I inserted, it always displayed as: abc xyz.

    What I intend to to is to display it as abc xyz with multiple white spaces. I tried abc &nbsp;xyz, and it displayed as abc &nbsp;xyz.

    How can I do it?

    Thanks to help.

  2. #2
    Join Date
    Dec 2005


    Put a non-displayable ASCII character into the string.
    For example: Alt-255 (Hold the Alt key while typing 255)
    var text ="abc            xyz";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles