www.webdeveloper.com
Results 1 to 4 of 4

Thread: Formatting text elements of <option> tags

  1. #1
    Join Date
    May 2004
    Posts
    1

    Formatting text elements of <option> tags

    Does anyone know of any way to italicize the text of an option tag? Specifically, I'm trying to italicize some entries in a select menu while leaving others alone. I have already attempted a few variations on the following with no success:

    <select name="mySelectMenu">

    <option> Blue pencils </option>
    <option><i>Red pencils</i> </option>
    <option><i>Green pencils</i></option>
    <option> Yellow pencils </option>

    </select>


    The desired result would be that only the 2nd and 3rd options in the dropdown menu would be italicized.

    Many thanks for any help provided...

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,119
    you will need to set the style for the
    select tag and it will reflect on options.
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,489
    Originally posted by Khalid Ali
    you will need to set the style for the select tag
    You could style the <select> element, however, the original poster implies that they want only specific options to be displayed as italic, and thus you must style the <option> element instead because styling <select> would result in all options becoming styled. All you'd need is:
    Code:
    <select>
    	<option value="foo">bar</option>
    	<option value="foo" class="i">bar</option>
    	<option value="foo" class="i">bar</option>
    	<option value="foo">bar</option>
    </select>
    Along with the following CSS:
    Code:
    <style type="text/css">
    /*<![CDATA[*/
    	.i { font-style: italic; }
    /*]]>*/
    </style>

  4. #4
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    You might want to check this out as an example. IE's support of the widget styles is quite pitiful so look at it with Mozilla or Firefox.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles