Style a <label> based on its <input>'s state
问题 Is it possible, with only CSS, to style an HTML label dependent on its input's state? In my case, I want to style an <input type="checkbox"> based on whether it's checked. I tried putting the label inside the input, but Firefox and Chrome (at least) seems to parse them as siblings, even though they're clearly nested in the input source. And I don't know how to write a CSS rule that can indirect through a for= attribute. Do I need to whip out the Javascript on this one? 回答1: They don't need to