formatting content inside a <option>

liunx

Guest
is there anyway to format the text inside an option tag?

I have a client who wants to have multiple styles within a single option tag (different colored text, bold text etc). I can change the font for the entire element or have such things as underlined text, but I have not been able to get colors to work and none of the extra formatting seems to work when the select box is not expanded.

Also, is there a way other than brute force to have <select> list maintain a certain width?Try this:<select style="width:40ex;">
<option style="color:#ff0000;">1</option>
<option style="color:#00ff00;">2</option>
<option style="color:#0000ff;">3</option>
</select>That sort of solves my problem (though netscape does not show the formatting when the list is collapsed). But what I am wondering is if it is possible to have multiple styles within a single option tag such as:


<option>BlackText RedText GreenText</option

ThanksHi!

Sorry: that is not possible in a select tag.

The only way to achieve this would be to create something which looks like a select tag, acts like it, but is something completely different.

Could be a table or a collections of divs/spans or a mixture of both.

Cheers - Pitthats what I thought. ThanksHi!

No problem. Will you be able to set such a thing up? It would depend on javascript - don't know, if you deal with that.

Cheers - PitI can do it in javascript but we are just canning the idea. It was one of those "if it works great, if not ohh well" things.

thanks for the input though, it helps to be able to go back to my superiors and justify saying no.Hi!thanks for the input though, it helps to be able to go back to my superiors and justify saying no.That's the best you can do, because if the question was: is that possible in a select tag, no is the cross browser and javascript disabled only answer. :D

Regards - PitOriginally posted by Pittimann
Could be a table or a collections of divs/spans or a mixture of both.Using a table would be incorrect, the proper way to do it would be to use an unordered list and style it accordingly.

The actualy menu could probably be done entirely in CSS, but the then the value selected would need to be transferred to a hidden input with JavaScript, therefore if this method were to be used you should have a normal dropdown in <noscript> tags.

However since this idea has been dropped, I guess none of this matters. :D
 
Back
Top