-3

Possible Duplicate:
how to style the option of a html “select”?

I have an HTML element and I want one of the options to be in italic. I don't remember where but I've seen select elements that have a combination of bold fonts and regular fonts; may be it was a custom-built control.

Here's the HTML:

<select>
   <option>select a timezone</option>
   <option value="0">Casablanca</option>
   <option value="0">Dublin, Edinburgh, Lisbon, London</option>
   <option value="60">Belgrade, Bratislava, Budapest, Ljubljana, Prague</option>
   <option value="60" style="font-style:italic;">Brussels, Copenhagen, Madrid, Paris</option>
</select>​

And here is the jsfiddle.

Thanks for your suggestions.

1
  • you're going to find options to style options very limited as IE and Safari have issues applying the full CSS spectrum to an option: webbugtrack.blogspot.ca/2007/11/… and in particular italic won't work in IE, Safari, or Chrome :-( Commented Nov 7, 2012 at 20:18

2 Answers 2

2

Here is a great reference on how to use font-style on an option tag. It seems that you can't do it in certain browsers, and there are certain limitations.

Sign up to request clarification or add additional context in comments.

Comments

1
option:nth-child(3){
 font-style:italic
}

http://jsfiddle.net/E7r8w/2/

alternatively you can use javascript.

http://jsfiddle.net/E7r8w/3/

2 Comments

This doesn't seem to work in Chrome, or IE. Does it work for you?
@ajon I didn't test in Chrome or IE... just firefox. i think the nth-child() selector is css3.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.