Friday 15 January 2010

Styling select options using span or strong?

Searching around, it looks as if this cannot be done in HTML with or without CSS.

To quote :
option tags do not allow other tags within them (it's not valid html).
firefox, for example, simply removes them from the DOM when it renders it. 


It's easy to style the whole option tag. What you don't seem to be able to do is to style just part of an option.


The application was a list of users within our village. Name formats will vary, and it won't always be obvious which is the right one to sort on. Eg "Newtown Tennis Club" might be known just as the "Tennis Club". The solution was to specify a separate sort name for each user, and to sort the options in that order. I wanted to highlight the sorted term in bold: cannot do. Capitalising is the best I have been able to do.


Isn't HTML a pain?

No comments: