/    Sign up×
Community /Pin to ProfileBookmark

style in a drop down list

Hi!!

I would like to put colour in some of the options of my drop down list, my code is the following (but it doesn’ work):

<select>
<option value=”one” style=”color:yellow;background-color:blue”>1</option>
<option value=”two”>2</option>
<option value=”three”>3</option>
<option value=”four”>4</option>
</select>

What do I have wrong? What can I do to add the colour to the option?

Thanks for you help.

to post a comment
HTML

8 Comments(s)

Copy linkTweet thisAlerts:
@soccer362001May 18.2004 — EDIT: Well obviously you can.
Copy linkTweet thisAlerts:
@DaveSWMay 18.2004 — Works fine in IE6

<select>

<option value="one" style="color:yellow;background-color:blue">1</option>

<option value="two" style="color:blue;background-color:yellow">2</option>

<option value="three" style="color:yellow;background-color:blue">3</option>

<option value="four" style="color:blue;background-color:yellow">4</option>

</select>

The focus is over the first one so it goes navy anyway.
Copy linkTweet thisAlerts:
@221436authorMay 18.2004 — It doesn't work for opera, mozilla or konkeror.

Any idea how can I do it for this browsers?? ?


Thanks for your help.
Copy linkTweet thisAlerts:
@DaveSWMay 18.2004 — This works for me in Firefox (0.8)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled</title>

<style type="text/css">

/*<![CDATA[*/

<!--

select {

background: red;

}

-->

/*]]>*/

</style>

</head>

<body>

<div><select>

<option value="one">1</option>

<option value="two">2</option>

<option value="three">3</option>

<option value="four">4</option>

</select></div>

</body>

</html>
Copy linkTweet thisAlerts:
@221436authorMay 19.2004 — But... this only works for the entire list and not for only some of the options, right?

I was trying to make it work for only some of the options, I know that the code is rigth but the problem is in the browser.

Is there any way I can make it work for different browsers??
Copy linkTweet thisAlerts:
@DaveSWMay 19.2004 — Could you style the select tag for all browsers, then use inline styles for your options so the browsers that can handle it can have diff colors?
Copy linkTweet thisAlerts:
@221436authorMay 19.2004 — mmmm.... that could work!!! :p

I will try that way.

Thanks for helping!!
Copy linkTweet thisAlerts:
@DaveSWMay 19.2004 — np ?
×

Success!

Help @221436 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...