...

View Full Version : Resolved Drop down list text colour?



DanielHowden
11-13-2010, 05:21 PM
Can I change the colour of the text in a drop down list? Or to be more precise can I change the colour of ONE of the items in the list?

Cheers Dan.

Chris Hick
11-13-2010, 08:23 PM
Of course, you can. Just add an id or class to your option tag. Here let me give you an example. Then style it in your css.

HTML and CSS:


<html>
<head>
<title></title>
<style type="text/css">
#red {
color: red;
}
#blue {
color: blue;
}
.green {
color: green;
}
</style>
</head>

<body>
<select name="country">
<optgroup label="Africa">
<option value="gam" id="red">Gambia</option>
<option value="mad" id="blue">Madagascar</option>
<option value="nam" class="green">Namibia</option>
</optgroup>
<optgroup label="Europe">
<option value="fra" class="green">France</option>
<option value="rus" class="green">Russia</option>
<option value="uk" class="green">UK</option>
</optgroup>
<optgroup label="North America">
<option value="can">Canada</option>
<option value="mex">Mexico</option>
<option value="usa">USA</option>
</optgroup>
</select>

</body>

</html>
Make sure to always validate @ http://validator.w3.org/ :thumbsup:
(http://validator.w3.org/)

DanielHowden
11-14-2010, 11:52 AM
That is awesome, thanks.

Chris Hick
11-14-2010, 02:11 PM
:thumbsup: You are welcome. Just remember to edit your first post and set it to resolved.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum