Click to See Complete Forum and Search --> : Styling radio buttons indepedantly of text inputs


Geat
12-03-2003, 07:39 AM
Okay, obviously:

input {background-color:#000000'}

will make the background colour of all default input elements black, but how about if I just need it to happen to inputs of type "radio", e.g.:

input:radio {background-color:#000000'}

Which doesn't work.

For the particular purpose I can't class up the radio buttons, it has to be any inputs that aren't overidden with a class that are affected.

Any ideas?

DaveSW
12-03-2003, 09:47 AM
could you nest them and class the element you nest them in? obviously then using
.nestedelement input {...}

Can't think of anything beyond that at the mo...

Geat
12-03-2003, 09:52 AM
That's a good idea, but unfortunately I cannot dictate what the HTML is that is going to be styled, and hence the styles I am applying must be to the defaults, and not classes thereof.

DaveSW
12-03-2003, 10:02 AM
Awkward...

I've checked out the w3c...
There is a selector that does exactly what you want, (I think) but as far as I'm aware nothing supports it...
http://www.w3.org/TR/CSS21/selector.html#q10

You might want to test it for yourself (I can't remember why I don't think anything supports it...)

DaveSW
12-03-2003, 10:10 AM
Here's my test page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
input { background-color:#ffffff; }
input[type="radio"] { background-color:#000000; }
-->
</style>

</head>
<body>
<input type="text" />
<input type="radio" />
</body>
</html>

There may be something wrong in the code, but it doesn't work in IE6 or NS7.1.

Geat
12-03-2003, 10:12 AM
Same here - I tried it in my code, but it doesn't appear to work. It's a damn shame, because those selector things sound really quite nifty...

DaveSW
12-03-2003, 10:16 AM
maybe in another 5 years... lol

Geat
12-03-2003, 10:19 AM
We can but hope!

The next incarnation of CSS is sounding pretty good...

DaveSW
12-03-2003, 10:24 AM
I wonder how long it will take to get support for that! We still haven't got full support for 2.1... I'll probably have grey hair by then lol.

Geat
12-03-2003, 10:28 AM
The guys behind the most popular browsers should really get their arses in gear... Us developers deserve an easier ride, that's for sure!

DaveSW
12-03-2003, 10:36 AM
CSS is great, it's just that the greatest things aren't supported! Still, since we don't pay directly for most of our browsers, we can't complain too loudly...

Geat
12-03-2003, 10:39 AM
This is true...