views:

136

answers:

4

How do you change the color of the "check" within an HTML checkbox?

By default, on WinXP Firefox/Chrome/IE - the check is green. I would like to change the check within an INPUT type="checkbox" to orange

A: 

Form widgets are black magic. You should ask over at http://doctype.com/ (Stack Overflow, but for designers)

Ben
do you think this question is not supposed to be here?
Anwar Chandra
I'm not saying that they don't belong here - they may get help. I'm just pointing them to a resource that was purpose-built for web design related questions, where they may get better help. Because that's where the experts in this specific area hang out. In fact, if you scroll down this page, you'll see that doctype.com is recommended by/associated with Stack Overflow.
Ben
A: 
<style>input[type=checkbox] { background-color: #F00; color: #0F0; } </style>
<input type="checkbox" CHECKED>

This is not a cross-browser solution (hey, IE!). Here's a more portable one:

<style> input.checkbox { background-color: #F00; color: #0F0; } </style>
<input type="checkbox" class="checkbox" CHECKED>
o_O Tync
-1 incorrect (fifteen characters)
Lord Torgamus
That worked in Opera for me.
o_O Tync
+2  A: 

There's no way to do this consistently with stock inputs. Safari, for one, will never respect your tweaks.

You can use JavaScript to present styled elements that function as checkboxes. Here's one plugin that uses jQuery.

ceejayoz
+1 for right answer and suggesting workarounds; I believe checkbox color is an OS setting, rather than an HTML or CSS or even browser setting.
Lord Torgamus
Scrollbars are also OS objects, but they're stylable.
o_O Tync
Not in all browsers, they're not.
ceejayoz
+1  A: 

As others have said, this isn't particularly easy to do in a cross-browser way.

But another possibility is jQuery UI which is highly customizable. You can even design a theme on their site. And along with all that you can use the jQuery UI Checkbox.

You could potentially roll your own lighter-weight version of all this with a combination of Javascript and CSS. But I imagine you'd run into a lot of compatibility issues that have already been figured out by the jQuery guys.

Steve Wortham