Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line Break in HTML Select Option?

Can I have a two line text in an html select option? How?

like image 598
Frank Michael Kraft Avatar asked May 19 '10 09:05

Frank Michael Kraft


People also ask

How do you break a line in HTML?

The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.

How do you select multiple lines in HTML?

If you want to select multiple options, you must press Ctrl + click to select more options. If you want to disable multiselect, just erase the "multiple" parameter from the SELECT tag. NOT multi-select, it's multi-line what he is looking for as he stated in his question.

How do you put a line break in space in HTML?

If you want to prevent a line break between two words, use a non-breaking space. If you want to insert a line break, use the HTML break tag, written as <br>. You don't need a closing tag here — just writing <br> adds a line break.


2 Answers

I know this is an older post, but I'm leaving this for whomever else comes looking in the future.

You can't format line breaks into an option; however, you can use the title attibute to give a mouse-over tooltip to give the full info. Use a short descriptor in the option text and give the full skinny in the title.

<option value="1" title="This is my lengthy explanation of what this selection really means, so since you only see 1 on the drop down list you really know that you're opting to elect me as King of Willywarts!  Always be sure to read the fine print!">1</option> 
like image 194
jcanker Avatar answered Sep 17 '22 12:09

jcanker


No, browsers don't provide this formatting option.

You could probably fake it with some checkboxes with <label>s, and JS to turn it into a fly out menu.

like image 28
Quentin Avatar answered Sep 19 '22 12:09

Quentin