pstidsen
pstidsen

Reputation: 39

Target radio button by value css

I have some HTML like:

<input type="radio" value="red" id="color" name="attribute_color">
<input type="radio" value="blue" id="color" name="attribute_color">
<input type="radio" value="green" id="color" name="attribute_color">

How can I target the different inputs WITHOUT adding any ID or class? Can I target by value?

Upvotes: 1

Views: 4849

Answers (1)

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123397

yes you can define your css rules like so:

input[value="red"] {
   /* style for red radio */
}

input[value="green"] {
   /* style for green radio */
}

input[value="blue"] {
   /* style for blue radio */
}

The attribute selector works on all browser and IE7+

Upvotes: 6

Related Questions