Search code examples
csscss-selectorsdynamic-css

How would I style the text following a :checked radio button?


I've tried the following:

:checked + *  
{  
font-weight: bold;  
}

With the following html:

<p><input type = "radio" name = "blah" />some text</p>

How would I go about styling such text?

Solution:

Throw label tags around the text, and select with
:selected + *

It works in opera and ff3, so I'm good.


Solution

  • You use the label element to associate text and other inline content with form inputs:

    <input id="foo" ...> <label for="foo" ...>foo text</label>
    

    And then select with [for="foo"] or #foo + label or whatever.