Hi All,

Is it possible to word wrap the selection options in HTML?

I want the use to choose between three sentenses, but they are pretty long, so would like to word wrap them.

Who is Participating?
Chad HaneyConnect With a Mentor Chief Technology OfficerCommented:
With the select option this is not possible.  As Identified by qwerty I would recomend an Ajax control, or create a custom control utilizing css to hide the options until the form button is clicked, then when the option is selected it populates a hidden input field with the select value, and you populate a readonly input box (or just a span) with the text value.

here is a mock up:
function showValues(){
function setValue(theValue, theText){

<input type="hidden" name="selectValue" id="selectValue"/>
<input type="text" readonly="readonly" onclick="showValues()" id="displayValue"/>
<ul id="selectOptions" style="display:none">
<li><a href="javascript:setValue('[SelectValue]', "Item 1");">Item 1</a></li>
<li><a href="javascript:setValue('[SelectValue]', "Item 2");">Item 2</a></li>
You can define word wrap in css and call that class in Select option. It is possible.
detox1978Author Commented:
can you provide a sample as i can't get that to work
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

<!-- html -->
<select name="mySelect">
    <option class="optionWrap"> ...</option>

/* css */
    width: 100px;

Set the width should do it.
detox1978Author Commented:
I want to word wrap (put one option on several lines).

The code you present, doesn't do this.
You need to create a custom control for this. Either a Telerik control or through Ajax ToolKit.

Refer this:
detox1978Author Commented:
can you give a little more information?
detox1978Author Commented:
I guess i could use CSS to make a combo looking box that does this.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.