Hi,
I have a simple select box defined like so:
<select name="colours">
<option value="blue">Blue</option>
<option value="red">Red</option>
</select>
What I want to do is have the background of each option value set to be the color of that option i.e. the 1st one should have black text on a blue background and so on.
I have no idea if it is possible to do this, I have tried styling it by giving the option an id and then styling it in the CSS file like so:
#lightBlue
{ background-color: #f2f7fd;
}
but that doesn't work and I also tried putting a nested <span> element in the option and styling that
<option value="defaultVal">
<span id="lightBlue">Default Color</span>
</option>
But that doesn't work either. Does anyone know can I actually do this and if so how?Yes you can: please visit:
<!-- m --><a class="postlink" href="http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/option.asp">http://msdn.microsoft.com/workshop/auth ... option.asp</a><!-- m --> and choose 'Styles'.
JayDieSee if this gives you any ideas.
<!-- m --><a class="postlink" href="http://blab-n-lab.home.comcast.net/lab/styletest.htmlOriginally">http://blab-n-lab.home.comcast.net/lab/ ... Originally</a><!-- m --> posted by ray326
See if this gives you any ideas.
<!-- m --><a class="postlink" href="http://blab-n-lab.home.comcast.net/lab/styletest.html">http://blab-n-lab.home.comcast.net/lab/styletest.html</a><!-- m -->
Hey, that's pretty neat. Never knew you could do that...It takes a real browser to handle it (IE need not appy) but my experiment came up with the thought, "These are just tags. I wonder if they can be styled." (Hmm, I wonder ... whaddayknow, it validates.)
I have a simple select box defined like so:
<select name="colours">
<option value="blue">Blue</option>
<option value="red">Red</option>
</select>
What I want to do is have the background of each option value set to be the color of that option i.e. the 1st one should have black text on a blue background and so on.
I have no idea if it is possible to do this, I have tried styling it by giving the option an id and then styling it in the CSS file like so:
#lightBlue
{ background-color: #f2f7fd;
}
but that doesn't work and I also tried putting a nested <span> element in the option and styling that
<option value="defaultVal">
<span id="lightBlue">Default Color</span>
</option>
But that doesn't work either. Does anyone know can I actually do this and if so how?Yes you can: please visit:
<!-- m --><a class="postlink" href="http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/option.asp">http://msdn.microsoft.com/workshop/auth ... option.asp</a><!-- m --> and choose 'Styles'.
JayDieSee if this gives you any ideas.
<!-- m --><a class="postlink" href="http://blab-n-lab.home.comcast.net/lab/styletest.htmlOriginally">http://blab-n-lab.home.comcast.net/lab/ ... Originally</a><!-- m --> posted by ray326
See if this gives you any ideas.
<!-- m --><a class="postlink" href="http://blab-n-lab.home.comcast.net/lab/styletest.html">http://blab-n-lab.home.comcast.net/lab/styletest.html</a><!-- m -->
Hey, that's pretty neat. Never knew you could do that...It takes a real browser to handle it (IE need not appy) but my experiment came up with the thought, "These are just tags. I wonder if they can be styled." (Hmm, I wonder ... whaddayknow, it validates.)