How do you select a radio button in css?

How do you select a radio button in CSS? The HTML I am working with is generated so I cannot add class or other attributes to it.

I found input[type="radio"] on the internet, but I don't know if this is regular CSS and supported by most browsers.

Is there any other ways to select a radio button?

Thank you,

Brett


Solution 1:

input[type="radio"] is an example of an attribute selector. It's part of the CSS3 spec and is perfectly legal. The only browser that doesn't support them is IE6. If supporting IE6 is important to the project, then you should look into adding classes to the radio buttons in question.

Here's an article with an example of how to effectively use attribute selectors. Check out this article for more info on CSS3 goodies.

Solution 2:

The attribute selector input[type="radio"] is the correct solution, widely supported by everything but IE6 :)

If you have no ability to modify the HTML to inject class name support or access to javascript to accomplish this then your options are:

  1. to make sure your site doesn't depend on this and allow IE6 to degrade gracefully.
  2. live without it