473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Setting Style for Select > Option

Is there a way to change the font-family and font-size for each
individual option in a select menu? Something along the lines of:

<select size="1">
<option style="font-family: Arial; font-size: 8px">One</option>
<option style="font-family: Tahoma; font-size: 10px">Two</option>
<option style="font-family: Verdana; font-size: 12px">Three</option>
</select>

I see that I can change the color using style="color: whatever", but
none of the other attributes change this way.

TIA,

Jason
Feb 5 '08 #1
3 52214
Scripsit Jason Carlton:
Is there a way to change the font-family and font-size for each
individual option in a select menu?
Yes, of course. And, of course, usual CSS Caveats apply.
<select size="1">
<option style="font-family: Arial; font-size: 8px">One</option>
<option style="font-family: Tahoma; font-size: 10px">Two</option>
<option style="font-family: Verdana; font-size: 12px">Three</option>
</select>
Of course, that's absurd, but so (though maybe less obviously) is almost
any idea of setting font family or size different in different options.
I see that I can change the color using style="color: whatever", but
none of the other attributes change this way.
Oh, it's just item #2 in the usual CSS Caveats:

"Not all browsers support CSS.
Not all browser versions support CSS to the same extent.
Not all users will have enabled CSS in CSS enabled browsers.
Some users of NN may have disabled Javascript, thus disabling CSS.
Some users may have enabled their own stylesheets, disabling yours.
CSS2 and CSS-P are moving targets. Use with care.
Font specification is problematic.
Unusual caveats may apply. ;-) "

http://www.dev-archive.net/articles/...S-caveats.html
(mostly ignore the disclaimer; the content, though old, is much more
fresh and meaningful than most of the CSS stuff around)

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 5 '08 #2
Jason Carlton wrote:
Is there a way to change the font-family and font-size for each
individual option in a select menu? Something along the lines of:

<select size="1">
<option style="font-family: Arial; font-size: 8px">One</option>
<option style="font-family: Tahoma; font-size: 10px">Two</option>
<option style="font-family: Verdana; font-size: 12px">Three</option>
</select>

I see that I can change the color using style="color: whatever", but
none of the other attributes change this way.
You can change background color too but this is circa all what you can do with
<optiontag :-)
I had similar problem as you few month ago and I resolve it by using
scrollable <divand series of checkboxes. Of course, this is workaround but
work for most used browsers.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)

Please reply to <petr AT practisoft DOT cz>

Feb 5 '08 #3
Scripsit Jukka K. Korpela:
http://www.dev-archive.net/articles/...S-caveats.html
(mostly ignore the disclaimer; the content, though old, is much more
fresh and meaningful than most of the CSS stuff around)
I decided to write a modernized and somewhat expanded version of the CSS
Caveats:
http://www.cs.tut.fi/~jkorpela/css-caveats.html

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 9 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jeff Anderson | last post by:
Is there a style for a select option's "selected" color? For example: <HTML> <BODY> <FORM NAME="form1"> <SELECT NAME="mySelect" SIZE="7" style="background-color:red;"> <OPTION>Test 1...
2
by: Manfred | last post by:
Hi I try to change the border of the <select> Tag to a thin, black line. On IE no reaction! <select style="border:1px solid #000000;background-color:red;"> <option>hallo</option>...
9
by: netclectic | last post by:
I'm dynamically adding options to a select list in javascript and i need to be able to set the height of the option, but setting style.height has not effect, I also tried style.pixelHeight but no...
6
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets...
6
by: Kermit Piper | last post by:
Hello, I thought this should be easy, but... all I want to do is set the value of this state drop-down based on a session var I'm getting back from a redirect (from the processing page): <%...
5
by: Isha | last post by:
Hi all, I wanted to change the background color for only the first option in a select box, but following changed the background color for the whole dropdown box. <select name="alltags"...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: Winston | last post by:
Where is the mistake? I want to make a simple menu. These are two pieces of two files... function ShowMenu(objeto) { is_open = document.getElementById(objeto).style.display;...
7
by: =?Utf-8?B?UmVraGE=?= | last post by:
Hi, I am trying to change the font color for the items in a dropdownlist control at run time using ASP.NET 2.0. DropDownList1.Items.Attributes.Add("style", "color:red"); But when I run the...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.